[5037] | 1 | !---------------------------------------------------------------------- |
---|
| 2 | ! NEMO system team, System and Interface for oceanic RElocable Nesting |
---|
| 3 | !---------------------------------------------------------------------- |
---|
| 4 | ! |
---|
| 5 | ! DESCRIPTION: |
---|
[13369] | 6 | !> @brief |
---|
[5037] | 7 | !> This module manage cubic interpolation on regular grid. |
---|
| 8 | !> |
---|
| 9 | !> |
---|
| 10 | !> @details |
---|
| 11 | !> to compute cubic interpolation:<br/> |
---|
| 12 | !> @code |
---|
| 13 | !> CALL interp_cubic_fill(dd_value, dd_fill, id_detect, id_rho, ld_even [,ld_discont] ) |
---|
| 14 | !> @endcode |
---|
[13369] | 15 | !> - dd_value is 2D array of variable value |
---|
[5037] | 16 | !> - dd_fill is the FillValue of variable |
---|
[13369] | 17 | !> - id_detect is 2D array of point to be interpolated (see interp module) |
---|
[5037] | 18 | !> - id_rho is array of refinment factor |
---|
[13369] | 19 | !> - ld_even indicates even refinment or not |
---|
[5037] | 20 | !> - ld_discont indicates longitudinal discontinuity (-180°/180°, 0°/360°) or not |
---|
| 21 | !> |
---|
| 22 | !> @author |
---|
| 23 | !> J.Paul |
---|
[12080] | 24 | !> |
---|
[5037] | 25 | !> @date September, 2014 -Initial version |
---|
[5609] | 26 | !> @date June, 2015 |
---|
| 27 | !> - use math module |
---|
[5037] | 28 | !> |
---|
[12080] | 29 | !> @note Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
[5037] | 30 | !---------------------------------------------------------------------- |
---|
| 31 | MODULE interp_cubic |
---|
| 32 | |
---|
| 33 | USE netcdf ! nf90 library |
---|
| 34 | USE global ! global variable |
---|
| 35 | USE kind ! F90 kind parameter |
---|
| 36 | USE logger ! log file manager |
---|
| 37 | USE fct ! basic useful function |
---|
[5609] | 38 | USE math ! mathematical function |
---|
[5037] | 39 | |
---|
| 40 | IMPLICIT NONE |
---|
| 41 | ! NOTE_avoid_public_variables_if_possible |
---|
| 42 | |
---|
| 43 | ! type and variable |
---|
| 44 | |
---|
| 45 | ! function and subroutine |
---|
| 46 | PUBLIC :: interp_cubic_fill !< compute interpolation using cubic method |
---|
| 47 | |
---|
| 48 | PRIVATE :: interp_cubic__2D !< compute bicubic interpolation on 2D gid |
---|
| 49 | PRIVATE :: interp_cubic__1D !< compute cubic interpolation on 1D gid |
---|
| 50 | PRIVATE :: interp_cubic__2D_coef !< compute coefficient for bicubic interpolation |
---|
| 51 | PRIVATE :: interp_cubic__2D_fill !< fill value using bicubic interpolation |
---|
| 52 | PRIVATE :: interp_cubic__1D_coef !< compute coefficient for cubic interpolation |
---|
| 53 | PRIVATE :: interp_cubic__1D_fill !< fill value using cubic interpolation |
---|
[13369] | 54 | PRIVATE :: interp_cubic__get_weight2D !< compute interpoaltion weight for 2D array |
---|
[5037] | 55 | PRIVATE :: interp_cubic__get_weight1D !< compute interpoaltion weight for 1D array |
---|
| 56 | |
---|
[12080] | 57 | CONTAINS |
---|
| 58 | !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 59 | SUBROUTINE interp_cubic_fill(dd_value, dd_fill, & |
---|
| 60 | & id_detect, & |
---|
| 61 | & id_rho, & |
---|
| 62 | & ld_even, ld_discont) |
---|
[5037] | 63 | !------------------------------------------------------------------- |
---|
| 64 | !> @brief |
---|
[13369] | 65 | !> This subroutine compute horizontal cubic interpolation on 4D array of value. |
---|
| 66 | !> |
---|
[5037] | 67 | !> @author J.Paul |
---|
[5609] | 68 | !> @date September, 2014 - Initial Version |
---|
[13369] | 69 | !> @date July, 2015 |
---|
[5609] | 70 | !> - reinitialise detect array for each level |
---|
[5037] | 71 | !> |
---|
[13369] | 72 | !> @param[inout] dd_value 2D array of variable value |
---|
[5037] | 73 | !> @param[in] dd_fill FillValue of variable |
---|
[13369] | 74 | !> @param[inout] id_detect 2D array of point to be interpolated |
---|
[5037] | 75 | !> @param[in] id_rho array of refinment factor |
---|
[13369] | 76 | !> @param[in] ld_even even refinment or not |
---|
[5037] | 77 | !> @param[in] ld_discont longitudinal discontinuity (-180°/180°, 0°/360°) or not |
---|
| 78 | !------------------------------------------------------------------- |
---|
[12080] | 79 | |
---|
[5037] | 80 | IMPLICIT NONE |
---|
[12080] | 81 | |
---|
[5037] | 82 | ! Argument |
---|
[13369] | 83 | REAL(dp) , DIMENSION(:,:,:,:), INTENT(INOUT) :: dd_value |
---|
| 84 | REAL(dp) , INTENT(IN ) :: dd_fill |
---|
[5037] | 85 | INTEGER(I4) , DIMENSION(:,:,:) , INTENT(INOUT) :: id_detect |
---|
| 86 | INTEGER(I4) , DIMENSION(:) , INTENT(IN ) :: id_rho |
---|
| 87 | LOGICAL , DIMENSION(:) , INTENT(IN ) :: ld_even |
---|
| 88 | LOGICAL , INTENT(IN ), OPTIONAL :: ld_discont |
---|
| 89 | |
---|
| 90 | ! local variable |
---|
[5609] | 91 | INTEGER(i4), DIMENSION(4) :: il_shape |
---|
[5037] | 92 | |
---|
[5609] | 93 | INTEGER(I4), DIMENSION(:,:,:), ALLOCATABLE :: il_detect |
---|
[5037] | 94 | |
---|
[5609] | 95 | LOGICAL :: ll_discont |
---|
| 96 | |
---|
| 97 | REAL(dp) , DIMENSION(:,:) , ALLOCATABLE :: dl_weight_IJ |
---|
| 98 | REAL(dp) , DIMENSION(:,:) , ALLOCATABLE :: dl_weight_I |
---|
| 99 | REAL(dp) , DIMENSION(:,:) , ALLOCATABLE :: dl_weight_J |
---|
[13369] | 100 | |
---|
[5037] | 101 | ! loop indices |
---|
| 102 | INTEGER(i4) :: ji |
---|
| 103 | INTEGER(i4) :: jj |
---|
| 104 | INTEGER(i4) :: jk |
---|
| 105 | INTEGER(i4) :: jl |
---|
| 106 | !---------------------------------------------------------------- |
---|
| 107 | ll_discont=.FALSE. |
---|
| 108 | IF( PRESENT(ld_discont) ) ll_discont=ld_discont |
---|
| 109 | |
---|
| 110 | il_shape(:)=SHAPE(dd_value) |
---|
| 111 | |
---|
| 112 | ! compute vect2D |
---|
| 113 | ALLOCATE(dl_weight_IJ(16,((id_rho(jp_I)+1)*(id_rho(jp_J)+1))) ) |
---|
| 114 | CALL interp_cubic__get_weight2D(dl_weight_IJ(:,:), & |
---|
| 115 | & id_rho(:), ld_even(:)) |
---|
| 116 | |
---|
| 117 | ALLOCATE( dl_weight_I( 4,((id_rho(jp_I)+1) )) ) |
---|
| 118 | ALLOCATE( dl_weight_J( 4,( (id_rho(jp_J)+1))) ) |
---|
| 119 | CALL interp_cubic__get_weight1D(dl_weight_I(:,:), & |
---|
| 120 | & id_rho(jp_I), ld_even(jp_I)) |
---|
| 121 | CALL interp_cubic__get_weight1D(dl_weight_J(:,:), & |
---|
| 122 | & id_rho(jp_J), ld_even(jp_J)) |
---|
| 123 | |
---|
[5609] | 124 | ALLOCATE(il_detect(il_shape(1),il_shape(2),il_shape(3))) |
---|
| 125 | |
---|
[5037] | 126 | DO jl=1,il_shape(4) |
---|
[5609] | 127 | il_detect(:,:,:)=id_detect(:,:,:) |
---|
[5037] | 128 | ! loop on vertical level |
---|
| 129 | DO jk=1,il_shape(3) |
---|
| 130 | |
---|
| 131 | ! I-J plan |
---|
| 132 | CALL interp_cubic__2D(dd_value(:,:,jk,jl), dd_fill, & |
---|
[5609] | 133 | & il_detect(:,:,jk), & |
---|
[5037] | 134 | & dl_weight_IJ(:,:), & |
---|
| 135 | & id_rho(jp_I), id_rho(jp_J), & |
---|
[13369] | 136 | & ll_discont) |
---|
[5609] | 137 | IF( ANY(il_detect(:,:,jk)==1) )THEN |
---|
[5037] | 138 | ! I direction |
---|
| 139 | DO jj=1,il_shape(2) |
---|
| 140 | CALL interp_cubic__1D( dd_value(:,jj,jk,jl), dd_fill, & |
---|
[5609] | 141 | & il_detect(:,jj,jk), & |
---|
[5037] | 142 | & dl_weight_I(:,:), & |
---|
| 143 | & id_rho(jp_I), ll_discont ) |
---|
| 144 | ENDDO |
---|
[5609] | 145 | IF( ALL(il_detect(:,:,jk)==0) )THEN |
---|
[5037] | 146 | CYCLE |
---|
| 147 | ELSE |
---|
| 148 | ! J direction |
---|
| 149 | DO ji=1,il_shape(1) |
---|
| 150 | CALL interp_cubic__1D( dd_value(ji,:,jk,jl), dd_fill, & |
---|
[5609] | 151 | & il_detect(ji,:,jk), & |
---|
[5037] | 152 | & dl_weight_J(:,:), & |
---|
| 153 | & id_rho(jp_J), ll_discont ) |
---|
| 154 | ENDDO |
---|
| 155 | ENDIF |
---|
| 156 | ENDIF |
---|
| 157 | |
---|
| 158 | ENDDO |
---|
| 159 | ENDDO |
---|
| 160 | |
---|
[5609] | 161 | id_detect(:,:,:)=il_detect(:,:,:) |
---|
| 162 | DEALLOCATE(il_detect) |
---|
| 163 | |
---|
[5037] | 164 | DEALLOCATE(dl_weight_IJ) |
---|
| 165 | DEALLOCATE(dl_weight_I) |
---|
| 166 | DEALLOCATE(dl_weight_J) |
---|
| 167 | |
---|
| 168 | END SUBROUTINE interp_cubic_fill |
---|
[12080] | 169 | !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 170 | SUBROUTINE interp_cubic__2D(dd_value, dd_fill, & |
---|
| 171 | & id_detect, & |
---|
| 172 | & dd_weight, & |
---|
| 173 | & id_rhoi, id_rhoj, & |
---|
| 174 | & ld_discont) |
---|
[5037] | 175 | !------------------------------------------------------------------- |
---|
| 176 | !> @brief |
---|
[13369] | 177 | !> This subroutine compute cubic interpolation on 2D array of value. |
---|
[5037] | 178 | !> |
---|
[13369] | 179 | !> @details |
---|
| 180 | !> |
---|
[5037] | 181 | !> @author J.Paul |
---|
[5609] | 182 | !> @date September, 2014 - Initial Version |
---|
[5037] | 183 | !> |
---|
[13369] | 184 | !> @param[inout] dd_value 2D array of variable value |
---|
[5037] | 185 | !> @param[in] dd_fill FillValue of variable |
---|
[13369] | 186 | !> @param[inout] id_detect 2D array of point to be interpolated |
---|
[5037] | 187 | !> @param[in] id_rhoi refinment factor in i-direction |
---|
| 188 | !> @param[in] id_rhoj refinment factor in j-direction |
---|
| 189 | !> @param[in] id_rhok refinment factor in k-direction |
---|
[13369] | 190 | !> @param[in] ld_even even refinment or not |
---|
[5037] | 191 | !> @param[in] ld_discont longitudinal discontinuity (-180°/180°, 0°/360°) or not |
---|
| 192 | !------------------------------------------------------------------- |
---|
| 193 | |
---|
| 194 | IMPLICIT NONE |
---|
[12080] | 195 | |
---|
[5037] | 196 | ! Argument |
---|
[13369] | 197 | REAL(dp) , DIMENSION(:,:), INTENT(INOUT) :: dd_value |
---|
| 198 | REAL(dp) , INTENT(IN ) :: dd_fill |
---|
[5037] | 199 | INTEGER(I4) , DIMENSION(:,:), INTENT(INOUT) :: id_detect |
---|
[5609] | 200 | REAL(dp) , DIMENSION(:,:), INTENT(IN ) :: dd_weight |
---|
[5037] | 201 | INTEGER(I4) , INTENT(IN ) :: id_rhoi |
---|
| 202 | INTEGER(I4) , INTENT(IN ) :: id_rhoj |
---|
| 203 | LOGICAL , INTENT(IN ) :: ld_discont |
---|
| 204 | |
---|
| 205 | ! local variable |
---|
| 206 | INTEGER(I4) :: il_xextra |
---|
| 207 | INTEGER(I4) :: il_yextra |
---|
| 208 | INTEGER(i4), DIMENSION(2) :: il_shape |
---|
| 209 | INTEGER(i4), DIMENSION(2) :: il_dim |
---|
| 210 | |
---|
[13369] | 211 | REAL(dp) :: dl_min |
---|
| 212 | REAL(dp) :: dl_max |
---|
[5037] | 213 | REAL(dp) , DIMENSION(:) , ALLOCATABLE :: dl_coef |
---|
| 214 | REAL(dp) , DIMENSION(:,:), ALLOCATABLE :: dl_coarse |
---|
| 215 | REAL(dp) , DIMENSION(:,:), ALLOCATABLE :: dl_tmp |
---|
| 216 | REAL(dp) , DIMENSION(:,:), ALLOCATABLE :: dl_dfdx |
---|
| 217 | REAL(dp) , DIMENSION(:,:), ALLOCATABLE :: dl_dfdy |
---|
| 218 | REAL(dp) , DIMENSION(:,:), ALLOCATABLE :: dl_d2fdxy |
---|
| 219 | |
---|
| 220 | ! loop indices |
---|
| 221 | INTEGER(i4) :: ji |
---|
| 222 | INTEGER(i4) :: jj |
---|
| 223 | INTEGER(i4) :: ii |
---|
| 224 | INTEGER(i4) :: ij |
---|
| 225 | !---------------------------------------------------------------- |
---|
| 226 | |
---|
| 227 | IF( ANY(id_detect(:,:)==1) )THEN |
---|
| 228 | il_shape(:)=SHAPE(dd_value) |
---|
| 229 | |
---|
| 230 | ! compute coarse grid dimension |
---|
| 231 | il_xextra=id_rhoi-1 |
---|
| 232 | il_dim(1)=(il_shape(1)+il_xextra)/id_rhoi |
---|
| 233 | |
---|
| 234 | il_yextra=id_rhoj-1 |
---|
| 235 | il_dim(2)=(il_shape(2)+il_yextra)/id_rhoj |
---|
| 236 | |
---|
| 237 | ALLOCATE( dl_coarse(il_dim(1),il_dim(2)) ) |
---|
| 238 | |
---|
| 239 | ! value on coarse grid |
---|
| 240 | dl_coarse(:,:)=dd_value( 1:il_shape(1):id_rhoi, & |
---|
| 241 | & 1:il_shape(2):id_rhoj ) |
---|
| 242 | |
---|
| 243 | ALLOCATE( dl_dfdx( il_dim(1),il_dim(2)), & |
---|
| 244 | & dl_dfdy( il_dim(1),il_dim(2)), & |
---|
| 245 | & dl_d2fdxy(il_dim(1),il_dim(2)) ) |
---|
| 246 | |
---|
| 247 | ! compute derivative on coarse grid |
---|
[5609] | 248 | dl_dfdx(:,:)=math_deriv_2D(dl_coarse(:,:), dd_fill, 'I', ld_discont) |
---|
| 249 | dl_dfdy(:,:)=math_deriv_2D(dl_coarse(:,:), dd_fill, 'J', ld_discont) |
---|
[5037] | 250 | |
---|
| 251 | ! compute cross derivative on coarse grid |
---|
[5609] | 252 | dl_d2fdxy(:,:)=math_deriv_2D(dl_dfdx(:,:), dd_fill, 'J', ld_discont) |
---|
[5037] | 253 | |
---|
| 254 | ALLOCATE( dl_tmp(2,2) ) |
---|
| 255 | ALLOCATE( dl_coef(16) ) |
---|
| 256 | |
---|
| 257 | DO jj=1,il_shape(2)-1,id_rhoj |
---|
| 258 | ij=((jj-1)/id_rhoj)+1 |
---|
| 259 | DO ji=1,il_shape(1)-1,id_rhoi |
---|
| 260 | ii=((ji-1)/id_rhoi)+1 |
---|
[13369] | 261 | |
---|
[5037] | 262 | ! check if point to be interpolated |
---|
| 263 | IF( ALL(id_detect(ji:ji+id_rhoi, & |
---|
| 264 | & jj:jj+id_rhoj)==0) ) CYCLE |
---|
| 265 | ! check data needed to interpolate |
---|
| 266 | IF( ANY(dl_coarse(ii:ii+1,ij:ij+1)==dd_fill) .OR. & |
---|
| 267 | & ANY( dl_dfdx(ii:ii+1,ij:ij+1)==dd_fill) .OR. & |
---|
| 268 | & ANY( dl_dfdy(ii:ii+1,ij:ij+1)==dd_fill) .OR. & |
---|
| 269 | & ANY(dl_d2fdxy(ii:ii+1,ij:ij+1)==dd_fill) ) CYCLE |
---|
| 270 | |
---|
| 271 | dl_tmp(:,:)=dl_coarse(ii:ii+1,ij:ij+1) |
---|
| 272 | ! check longitude discontinuity |
---|
| 273 | IF( ld_discont )THEN |
---|
| 274 | |
---|
| 275 | dl_min=MINVAL( dl_tmp(:,:), dl_tmp(:,:)/=dd_fill ) |
---|
| 276 | dl_max=MAXVAL( dl_tmp(:,:), dl_tmp(:,:)/=dd_fill ) |
---|
| 277 | IF( dl_min < -170_dp .AND. dl_max > 170_dp )THEN |
---|
[13369] | 278 | WHERE( dl_tmp(:,:) < 0_dp ) |
---|
[5037] | 279 | dl_tmp(:,:) = dl_tmp(:,:)+360._dp |
---|
| 280 | END WHERE |
---|
| 281 | ELSEIF( dl_min < 10_dp .AND. dl_max > 350_dp )THEN |
---|
[13369] | 282 | WHERE( dl_tmp(:,:) > 180_dp ) |
---|
[5037] | 283 | dl_tmp(:,:) = dl_tmp(:,:)-180._dp |
---|
| 284 | END WHERE |
---|
| 285 | ENDIF |
---|
| 286 | |
---|
| 287 | ENDIF |
---|
| 288 | |
---|
| 289 | ! compute bicubic coefficient |
---|
| 290 | dl_coef(:)=interp_cubic__2D_coef(dl_tmp(:,:),& |
---|
| 291 | & dl_dfdx( ii:ii+1,ij:ij+1),& |
---|
| 292 | & dl_dfdy( ii:ii+1,ij:ij+1),& |
---|
| 293 | & dl_d2fdxy(ii:ii+1,ij:ij+1),& |
---|
| 294 | & dd_fill ) |
---|
| 295 | |
---|
| 296 | ! compute value on detetected point |
---|
| 297 | CALL interp_cubic__2D_fill(dd_value( ji:ji+id_rhoi, & |
---|
| 298 | & jj:jj+id_rhoj ), & |
---|
| 299 | & id_detect(ji:ji+id_rhoi, & |
---|
| 300 | & jj:jj+id_rhoj ), & |
---|
| 301 | & dd_weight(:,:), dl_coef(:),& |
---|
| 302 | & dd_fill, id_rhoi, id_rhoj ) |
---|
| 303 | |
---|
| 304 | IF( ld_discont )THEN |
---|
| 305 | WHERE( dd_value( ji:ji+id_rhoi, & |
---|
| 306 | & jj:jj+id_rhoj ) >= 180._dp .AND. & |
---|
| 307 | & dd_value( ji:ji+id_rhoi, & |
---|
| 308 | & jj:jj+id_rhoj ) /= dd_fill ) |
---|
| 309 | dd_value( ji:ji+id_rhoi, & |
---|
| 310 | & jj:jj+id_rhoj ) = & |
---|
| 311 | & dd_value( ji:ji+id_rhoi, & |
---|
| 312 | & jj:jj+id_rhoj ) - 360._dp |
---|
| 313 | END WHERE |
---|
| 314 | ENDIF |
---|
| 315 | |
---|
| 316 | ENDDO |
---|
| 317 | ENDDO |
---|
| 318 | |
---|
| 319 | DEALLOCATE(dl_coef) |
---|
| 320 | DEALLOCATE(dl_tmp ) |
---|
| 321 | |
---|
| 322 | DEALLOCATE(dl_dfdx, & |
---|
| 323 | & dl_dfdy, & |
---|
| 324 | & dl_d2fdxy ) |
---|
| 325 | |
---|
| 326 | DEALLOCATE( dl_coarse ) |
---|
| 327 | ENDIF |
---|
| 328 | |
---|
| 329 | END SUBROUTINE interp_cubic__2D |
---|
[12080] | 330 | !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 331 | SUBROUTINE interp_cubic__1D(dd_value, dd_fill, & |
---|
| 332 | & id_detect, & |
---|
| 333 | & dd_weight, & |
---|
| 334 | & id_rhoi, & |
---|
| 335 | & ld_discont) |
---|
[5037] | 336 | !------------------------------------------------------------------- |
---|
| 337 | !> @brief |
---|
[13369] | 338 | !> This subroutine compute cubic interpolation on 1D array of value. |
---|
[5037] | 339 | !> |
---|
[13369] | 340 | !> @details |
---|
| 341 | !> |
---|
[5037] | 342 | !> @author J.Paul |
---|
[5609] | 343 | !> @date September, 2014 - Initial Version |
---|
[5037] | 344 | !> |
---|
[13369] | 345 | !> @param[inout] dd_value 1D array of variable value |
---|
[5037] | 346 | !> @param[in] dd_fill FillValue of variable |
---|
[13369] | 347 | !> @param[inout] id_detect 1D array of point to be interpolated |
---|
[5037] | 348 | !> @param[in] id_rhoi refinment factor |
---|
[13369] | 349 | !> @param[in] ld_even even refinment or not |
---|
[5037] | 350 | !> @param[in] ld_discont longitudinal discontinuity (-180°/180°, 0°/360°) or not |
---|
| 351 | !------------------------------------------------------------------- |
---|
| 352 | |
---|
| 353 | IMPLICIT NONE |
---|
[12080] | 354 | |
---|
[5037] | 355 | ! Argument |
---|
[13369] | 356 | REAL(dp) , DIMENSION(:) , INTENT(INOUT) :: dd_value |
---|
| 357 | REAL(dp) , INTENT(IN ) :: dd_fill |
---|
[5037] | 358 | INTEGER(I4) , DIMENSION(:) , INTENT(INOUT) :: id_detect |
---|
[5609] | 359 | REAL(dp) , DIMENSION(:,:), INTENT(IN ) :: dd_weight |
---|
[5037] | 360 | INTEGER(I4) , INTENT(IN ) :: id_rhoi |
---|
| 361 | LOGICAL , INTENT(IN ) :: ld_discont |
---|
| 362 | |
---|
| 363 | ! local variable |
---|
| 364 | INTEGER(I4) :: il_xextra |
---|
| 365 | INTEGER(i4), DIMENSION(1) :: il_shape |
---|
| 366 | INTEGER(i4), DIMENSION(1) :: il_dim |
---|
| 367 | |
---|
[13369] | 368 | REAL(dp) :: dl_min |
---|
| 369 | REAL(dp) :: dl_max |
---|
[5037] | 370 | REAL(dp) , DIMENSION(:), ALLOCATABLE :: dl_coef |
---|
| 371 | REAL(dp) , DIMENSION(:), ALLOCATABLE :: dl_coarse |
---|
| 372 | REAL(dp) , DIMENSION(:), ALLOCATABLE :: dl_tmp |
---|
| 373 | REAL(dp) , DIMENSION(:), ALLOCATABLE :: dl_dfdx |
---|
| 374 | |
---|
| 375 | ! loop indices |
---|
| 376 | INTEGER(i4) :: ji |
---|
| 377 | INTEGER(i4) :: ii |
---|
| 378 | !---------------------------------------------------------------- |
---|
| 379 | |
---|
| 380 | IF( ANY(id_detect(:)==1) )THEN |
---|
| 381 | il_shape(:)=SHAPE(dd_value) |
---|
| 382 | |
---|
| 383 | ! compute coarse grid dimension |
---|
| 384 | il_xextra=id_rhoi-1 |
---|
| 385 | il_dim(1)=(il_shape(1)+il_xextra)/id_rhoi |
---|
| 386 | |
---|
| 387 | ALLOCATE( dl_coarse(il_dim(1)) ) |
---|
| 388 | |
---|
| 389 | ! value on coarse grid |
---|
| 390 | dl_coarse(:)=dd_value( 1:il_shape(1):id_rhoi ) |
---|
| 391 | |
---|
| 392 | ALLOCATE( dl_dfdx(il_dim(1)) ) |
---|
| 393 | |
---|
| 394 | ! compute derivative on coarse grid |
---|
[5609] | 395 | dl_dfdx(:)=math_deriv_1D(dl_coarse(:), dd_fill, ld_discont) |
---|
[5037] | 396 | |
---|
| 397 | ALLOCATE( dl_tmp(2) ) |
---|
| 398 | ALLOCATE( dl_coef(4) ) |
---|
| 399 | |
---|
| 400 | DO ji=1,il_shape(1)-1,id_rhoi |
---|
| 401 | ii=((ji-1)/id_rhoi)+1 |
---|
[13369] | 402 | |
---|
[5037] | 403 | ! check if point to be interpolated |
---|
| 404 | IF( ALL(id_detect(ji:ji+id_rhoi)==0) ) CYCLE |
---|
| 405 | ! check data needed to interpolate |
---|
| 406 | IF( ANY(dl_coarse(ii:ii+1)==dd_fill) .OR. & |
---|
| 407 | & ANY( dl_dfdx(ii:ii+1)==dd_fill) ) CYCLE |
---|
| 408 | ! check longitude discontinuity |
---|
| 409 | dl_tmp(:)=dl_coarse(ii:ii+1) |
---|
| 410 | IF( ld_discont )THEN |
---|
| 411 | |
---|
| 412 | dl_min=MINVAL( dl_tmp(:), dl_tmp(:)/=dd_fill ) |
---|
| 413 | dl_max=MAXVAL( dl_tmp(:), dl_tmp(:)/=dd_fill ) |
---|
| 414 | IF( dl_min < -170_dp .AND. dl_max > 170_dp )THEN |
---|
[13369] | 415 | WHERE( dl_tmp(:) < 0_dp ) |
---|
[5037] | 416 | dl_tmp(:) = dl_tmp(:)+360._dp |
---|
| 417 | END WHERE |
---|
| 418 | ELSEIF( dl_min < 10_dp .AND. dl_max > 350_dp )THEN |
---|
[13369] | 419 | WHERE( dl_tmp(:) > 180_dp ) |
---|
[5037] | 420 | dl_tmp(:) = dl_tmp(:)-180._dp |
---|
| 421 | END WHERE |
---|
| 422 | ENDIF |
---|
| 423 | |
---|
| 424 | ENDIF |
---|
| 425 | |
---|
| 426 | ! compute bicubic coefficient |
---|
| 427 | dl_coef(:)=interp_cubic__1D_coef(dl_tmp(:), & |
---|
| 428 | & dl_dfdx(ii:ii+1),& |
---|
| 429 | & dd_fill ) |
---|
| 430 | |
---|
| 431 | ! compute value on detetected point |
---|
| 432 | CALL interp_cubic__1D_fill( dd_value( ji:ji+id_rhoi ), & |
---|
| 433 | & id_detect(ji:ji+id_rhoi ), & |
---|
| 434 | & dd_weight(:,:), dl_coef(:), & |
---|
| 435 | & dd_fill, id_rhoi ) |
---|
| 436 | |
---|
| 437 | IF( ld_discont )THEN |
---|
| 438 | WHERE( dd_value( ji:ji+id_rhoi ) >= 180._dp .AND. & |
---|
| 439 | & dd_value( ji:ji+id_rhoi ) /= dd_fill ) |
---|
| 440 | dd_value(ji:ji+id_rhoi) = dd_value(ji:ji+id_rhoi) - 360._dp |
---|
| 441 | END WHERE |
---|
| 442 | ENDIF |
---|
| 443 | |
---|
| 444 | ENDDO |
---|
| 445 | |
---|
| 446 | DEALLOCATE(dl_coef) |
---|
| 447 | DEALLOCATE(dl_tmp ) |
---|
| 448 | |
---|
| 449 | DEALLOCATE(dl_dfdx ) |
---|
| 450 | DEALLOCATE( dl_coarse ) |
---|
| 451 | ENDIF |
---|
| 452 | |
---|
| 453 | END SUBROUTINE interp_cubic__1D |
---|
[12080] | 454 | !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 455 | FUNCTION interp_cubic__2D_coef(dd_value, & |
---|
| 456 | & dd_dfdx, dd_dfdy, dd_d2fdxy,& |
---|
| 457 | & dd_fill) & |
---|
| 458 | & RESULT (df_coef) |
---|
[5037] | 459 | !------------------------------------------------------------------- |
---|
| 460 | !> @brief |
---|
| 461 | !> This subroutine compute 2D array of coefficient for cubic interpolation. |
---|
[13369] | 462 | !> |
---|
[5037] | 463 | !> @author J.Paul |
---|
[5609] | 464 | !> @date September, 2014 - Initial Version |
---|
[5037] | 465 | !> |
---|
| 466 | !> @param[in] dd_value 2D array of value |
---|
[13369] | 467 | !> @param[in] dd_dfdx 2D array of first derivative in i-direction |
---|
[5037] | 468 | !> @param[in] dd_dfdy 2D array of first derivative in j-direction |
---|
| 469 | !> @param[in] dd_d2fdxy 2D array of cross derivative in i-j-direction |
---|
| 470 | !> @param[in] dd_fill FillValue of variable |
---|
| 471 | !------------------------------------------------------------------- |
---|
[12080] | 472 | |
---|
[5037] | 473 | IMPLICIT NONE |
---|
[12080] | 474 | |
---|
[5037] | 475 | ! Argument |
---|
[13369] | 476 | REAL(dp), DIMENSION(:,:), INTENT(IN) :: dd_value |
---|
| 477 | REAL(dp), DIMENSION(:,:), INTENT(IN) :: dd_dfdx |
---|
| 478 | REAL(dp), DIMENSION(:,:), INTENT(IN) :: dd_dfdy |
---|
[5037] | 479 | REAL(dp), DIMENSION(:,:), INTENT(IN) :: dd_d2fdxy |
---|
| 480 | REAL(dp) , INTENT(IN) :: dd_fill |
---|
| 481 | |
---|
| 482 | ! function |
---|
[12080] | 483 | REAL(dp), DIMENSION(16) :: df_coef |
---|
[5037] | 484 | |
---|
| 485 | ! local variable |
---|
| 486 | REAL(dp), DIMENSION(16,16), PARAMETER :: dl_matrix = RESHAPE( & |
---|
[13369] | 487 | & (/ 1 , 0 ,-3 , 2 , 0 , 0 , 0 , 0 ,-3 , 0 , 9 ,-6 , 2 , 0 ,-6 , 4 ,& |
---|
| 488 | 0 , 0 , 3 ,-2 , 0 , 0 , 0 , 0 , 0 , 0 ,-9 , 6 , 0 , 0 , 6 ,-4 ,& |
---|
| 489 | 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 3 , 0 ,-9 , 6 ,-2 , 0 , 6 ,-4 ,& |
---|
| 490 | 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 9 ,-6 , 0 , 0 ,-6 , 4 ,& |
---|
| 491 | 0 , 1 ,-2 , 1 , 0 , 0 , 0 , 0 , 0 ,-3 , 6 ,-3 , 0 , 2 ,-4 , 2 ,& |
---|
| 492 | 0 , 0 ,-1 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 3 ,-3 , 0 , 0 ,-2 , 2 ,& |
---|
| 493 | 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 3 ,-6 , 3 , 0 ,-2 , 4 ,-2 ,& |
---|
| 494 | 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,-3 , 3 , 0 , 0 , 2 ,-2 ,& |
---|
| 495 | 0 , 0 , 0 , 0 , 1 , 0 ,-3 , 2 ,-2 , 0 , 6 ,-4 , 1 , 0 ,-3 , 2 ,& |
---|
| 496 | 0 , 0 , 0 , 0 , 0 , 0 , 3 ,-2 , 0 , 0 ,-6 , 4 , 0 , 0 , 3 ,-2 ,& |
---|
| 497 | 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,-1 , 0 , 3 ,-2 , 1 , 0 ,-3 , 2 ,& |
---|
| 498 | 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,-3 , 2 , 0 , 0 , 3 ,-2 ,& |
---|
| 499 | 0 , 0 , 0 , 0 , 0 , 1 ,-2 , 1 , 0 ,-2 , 4 ,-2 , 0 , 1 ,-2 , 1 ,& |
---|
| 500 | 0 , 0 , 0 , 0 , 0 , 0 ,-1 , 1 , 0 , 0 , 2 ,-2 , 0 , 0 ,-1 , 1 ,& |
---|
| 501 | 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,-1 , 2 ,-1 , 0 , 1 ,-2 , 1 ,& |
---|
[5037] | 502 | 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 ,-1 , 0 , 0 ,-1 , 1 /), & |
---|
| 503 | & (/ 16, 16 /) ) |
---|
| 504 | |
---|
| 505 | REAL(dp), DIMENSION(16) :: dl_vect |
---|
| 506 | |
---|
| 507 | !---------------------------------------------------------------- |
---|
| 508 | ! init |
---|
[12080] | 509 | df_coef(:)=dd_fill |
---|
[5037] | 510 | |
---|
| 511 | dl_vect( 1: 4)=PACK(dd_value(:,:),.TRUE. ) |
---|
| 512 | dl_vect( 5: 8)=PACK(dd_dfdx(:,:),.TRUE. ) |
---|
| 513 | dl_vect( 9:12)=PACK(dd_dfdy(:,:),.TRUE. ) |
---|
| 514 | dl_vect(13:16)=PACK(dd_d2fdxy(:,:),.TRUE. ) |
---|
| 515 | |
---|
[12080] | 516 | df_coef(:)=MATMUL(dl_matrix(:,:),dl_vect(:)) |
---|
[5037] | 517 | |
---|
| 518 | END FUNCTION interp_cubic__2D_coef |
---|
[12080] | 519 | !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 520 | SUBROUTINE interp_cubic__2D_fill(dd_value, id_detect, & |
---|
| 521 | & dd_weight, dd_coef, & |
---|
| 522 | & dd_fill, id_rhoi, id_rhoj) |
---|
[5037] | 523 | !------------------------------------------------------------------- |
---|
| 524 | !> @brief |
---|
[13369] | 525 | !> This subroutine compute cubic interpolation of a 2D array of value. |
---|
| 526 | !> |
---|
[5037] | 527 | !> @author J.Paul |
---|
[5609] | 528 | !> @date September, 2014 - Initial Version |
---|
[5037] | 529 | !> |
---|
| 530 | !> @param[inout] dd_value 2D array of mixed grid value |
---|
| 531 | !> @param[inout] id_detect 2D array of point to be interpolated |
---|
| 532 | !> @param[in] dd_coef 2D array of coefficient |
---|
| 533 | !> @param[in] dd_fill FillValue of variable |
---|
| 534 | !> @param[in] ld_even even refinment or not |
---|
[13369] | 535 | !> @param[in] id_rhoi refinement factor in i-direction |
---|
[5037] | 536 | !> @param[in] id_rhoj refinement factor in j-direction |
---|
| 537 | !------------------------------------------------------------------- |
---|
[12080] | 538 | |
---|
[5037] | 539 | IMPLICIT NONE |
---|
[12080] | 540 | |
---|
[5037] | 541 | ! Argument |
---|
[13369] | 542 | REAL(dp) , DIMENSION(:,:), INTENT(INOUT) :: dd_value |
---|
[5037] | 543 | INTEGER(i4) , DIMENSION(:,:), INTENT(INOUT) :: id_detect |
---|
| 544 | REAL(dp) , DIMENSION(:,:), INTENT(IN ) :: dd_weight |
---|
[13369] | 545 | REAL(dp) , DIMENSION(:) , INTENT(IN ) :: dd_coef |
---|
| 546 | REAL(dp) , INTENT(IN ) :: dd_fill |
---|
[5037] | 547 | INTEGER(I4) , INTENT(IN ) :: id_rhoi |
---|
| 548 | INTEGER(I4) , INTENT(IN ) :: id_rhoj |
---|
| 549 | |
---|
| 550 | ! local variable |
---|
| 551 | |
---|
| 552 | ! loop indices |
---|
| 553 | INTEGER(i4) :: ii |
---|
| 554 | |
---|
| 555 | INTEGER(i4) :: ji |
---|
| 556 | INTEGER(i4) :: jj |
---|
| 557 | !---------------------------------------------------------------- |
---|
| 558 | |
---|
| 559 | IF( ANY( dd_coef(:)==dd_fill ) )THEN |
---|
| 560 | CALL logger_error("INTERP CUBIC FILL: fill value detected in coef . "//& |
---|
| 561 | & "can not compute interpolation.") |
---|
| 562 | ELSE |
---|
| 563 | |
---|
| 564 | ii=0 |
---|
| 565 | DO jj=1,id_rhoj+1 |
---|
| 566 | DO ji=1,id_rhoi+1 |
---|
[13369] | 567 | |
---|
[5037] | 568 | ii=ii+1 |
---|
| 569 | IF(id_detect(ji,jj)==1)THEN |
---|
[13369] | 570 | |
---|
[5037] | 571 | dd_value(ji,jj)=DOT_PRODUCT(dd_coef(:),dd_weight(:,ii)) |
---|
| 572 | id_detect(ji,jj)=0 |
---|
| 573 | |
---|
| 574 | ENDIF |
---|
| 575 | |
---|
| 576 | ENDDO |
---|
| 577 | ENDDO |
---|
| 578 | |
---|
| 579 | ENDIF |
---|
| 580 | |
---|
| 581 | END SUBROUTINE interp_cubic__2D_fill |
---|
[12080] | 582 | !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 583 | FUNCTION interp_cubic__1D_coef(dd_value, & |
---|
| 584 | & dd_dfdx, & |
---|
| 585 | & dd_fill) & |
---|
| 586 | & RESULT (df_coef) |
---|
[5037] | 587 | !------------------------------------------------------------------- |
---|
| 588 | !> @brief |
---|
[13369] | 589 | !> This subroutine compute 1D array of coefficient for cubic interpolation. |
---|
[5037] | 590 | !> |
---|
[13369] | 591 | !> @details |
---|
| 592 | !> |
---|
[5037] | 593 | !> @author J.Paul |
---|
[5609] | 594 | !> @date September, 2014 - Initial Version |
---|
[5037] | 595 | !> |
---|
| 596 | !> @param[in] dd_value 1D array of value |
---|
[13369] | 597 | !> @param[in] dd_dfdx 1D array of first derivative |
---|
[5037] | 598 | !> @param[in] dd_fill FillValue of variable |
---|
| 599 | !------------------------------------------------------------------- |
---|
[12080] | 600 | |
---|
[5037] | 601 | IMPLICIT NONE |
---|
[12080] | 602 | |
---|
[5037] | 603 | ! Argument |
---|
[13369] | 604 | REAL(dp), DIMENSION(:) , INTENT(IN) :: dd_value |
---|
| 605 | REAL(dp), DIMENSION(:) , INTENT(IN) :: dd_dfdx |
---|
| 606 | REAL(dp) , INTENT(IN) :: dd_fill |
---|
[5037] | 607 | |
---|
| 608 | ! function |
---|
[12080] | 609 | REAL(dp), DIMENSION(4) :: df_coef |
---|
[5037] | 610 | |
---|
| 611 | ! local variable |
---|
| 612 | REAL(dp), DIMENSION(4,4), PARAMETER :: dl_matrix = RESHAPE( & |
---|
[13369] | 613 | & (/ 1 ,-1 ,-3 , 2 ,& |
---|
| 614 | 0 , 1 , 3 ,-2 ,& |
---|
| 615 | 0 , 0 ,-2 , 1 ,& |
---|
[5037] | 616 | 0 , 0 ,-1 , 1 /), & |
---|
[13369] | 617 | & (/ 4, 4 /) ) |
---|
[5037] | 618 | |
---|
| 619 | REAL(dp), DIMENSION(4) :: dl_vect |
---|
| 620 | |
---|
| 621 | !---------------------------------------------------------------- |
---|
| 622 | ! init |
---|
[12080] | 623 | df_coef(:)=dd_fill |
---|
[5037] | 624 | |
---|
| 625 | dl_vect( 1: 2)=PACK(dd_value(:),.TRUE. ) |
---|
| 626 | dl_vect( 3: 4)=PACK(dd_dfdx(:),.TRUE. ) |
---|
| 627 | |
---|
[12080] | 628 | df_coef(:)=MATMUL(dl_matrix(:,:),dl_vect(:)) |
---|
[5037] | 629 | |
---|
| 630 | END FUNCTION interp_cubic__1D_coef |
---|
[12080] | 631 | !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 632 | SUBROUTINE interp_cubic__1D_fill(dd_value, id_detect, & |
---|
| 633 | & dd_weight, dd_coef, & |
---|
| 634 | & dd_fill, id_rhoi) |
---|
[5037] | 635 | !------------------------------------------------------------------- |
---|
| 636 | !> @brief |
---|
[13369] | 637 | !> This subroutine compute cubic interpolation of a 1D array of value. |
---|
| 638 | !> |
---|
[5037] | 639 | !> @author J.Paul |
---|
[5609] | 640 | !> @date September, 2014 - Initial Version |
---|
[5037] | 641 | !> |
---|
| 642 | !> @param[inout] dd_value 1D array of mixed grid value |
---|
| 643 | !> @param[inout] id_detect 1D array of point to be interpolated |
---|
| 644 | !> @param[in] dd_coef 1D array of coefficient |
---|
| 645 | !> @param[in] dd_fill FillValue of variable |
---|
| 646 | !> @param[in] ld_even even refinment or not |
---|
[13369] | 647 | !> @param[in] id_rho refinement factor |
---|
[5037] | 648 | !------------------------------------------------------------------- |
---|
[12080] | 649 | |
---|
[5037] | 650 | IMPLICIT NONE |
---|
[12080] | 651 | |
---|
[5037] | 652 | ! Argument |
---|
[13369] | 653 | REAL(dp) , DIMENSION(:) , INTENT(INOUT) :: dd_value |
---|
[5037] | 654 | INTEGER(i4) , DIMENSION(:) , INTENT(INOUT) :: id_detect |
---|
[13369] | 655 | REAL(dp) , DIMENSION(:,:), INTENT(IN ) :: dd_weight |
---|
| 656 | REAL(dp) , DIMENSION(4) , INTENT(IN ) :: dd_coef |
---|
| 657 | REAL(dp) , INTENT(IN ) :: dd_fill |
---|
[5037] | 658 | INTEGER(I4) , INTENT(IN ) :: id_rhoi |
---|
| 659 | |
---|
| 660 | ! local variable |
---|
| 661 | ! loop indices |
---|
| 662 | INTEGER(i4) :: ji |
---|
| 663 | !---------------------------------------------------------------- |
---|
| 664 | |
---|
| 665 | IF( ANY( dd_coef(:)==dd_fill ) )THEN |
---|
| 666 | CALL logger_error("INTERP CUBIC FILL: fill value detected. "//& |
---|
| 667 | & "can not compute interpolation") |
---|
| 668 | ELSE |
---|
| 669 | |
---|
| 670 | DO ji=1,id_rhoi+1 |
---|
[13369] | 671 | |
---|
[5037] | 672 | IF(id_detect(ji)==1)THEN |
---|
| 673 | |
---|
| 674 | dd_value(ji)=DOT_PRODUCT(dd_coef(:),dd_weight(:,ji)) |
---|
| 675 | id_detect(ji)=0 |
---|
| 676 | |
---|
| 677 | ENDIF |
---|
| 678 | |
---|
| 679 | ENDDO |
---|
| 680 | |
---|
| 681 | ENDIF |
---|
| 682 | |
---|
| 683 | END SUBROUTINE interp_cubic__1D_fill |
---|
[12080] | 684 | !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 685 | SUBROUTINE interp_cubic__get_weight2D(dd_weight, & |
---|
| 686 | & id_rho, ld_even) |
---|
[5037] | 687 | !------------------------------------------------------------------- |
---|
| 688 | !> @brief |
---|
[13369] | 689 | !> This subroutine compute interpoaltion weight for 2D array. |
---|
| 690 | !> |
---|
[5037] | 691 | !> @author J.Paul |
---|
[5609] | 692 | !> @date September, 2014 - Initial Version |
---|
[5037] | 693 | !> |
---|
| 694 | !> @param[in] dd_weight interpolation weight of 2D array |
---|
| 695 | !> @param[in] ld_even even refinment or not |
---|
[13369] | 696 | !> @param[in] id_rho refinement factor |
---|
[5037] | 697 | !------------------------------------------------------------------- |
---|
[12080] | 698 | |
---|
[5037] | 699 | IMPLICIT NONE |
---|
[12080] | 700 | |
---|
[5037] | 701 | ! Argument |
---|
| 702 | REAL(dp) , DIMENSION(:,:), INTENT(INOUT) :: dd_weight |
---|
| 703 | INTEGER(I4), DIMENSION(:) , INTENT(IN ) :: id_rho |
---|
| 704 | LOGICAL , DIMENSION(:) , INTENT(IN ) :: ld_even |
---|
| 705 | |
---|
| 706 | ! local variable |
---|
| 707 | REAL(dp) :: dl_dx |
---|
[13369] | 708 | REAL(dp) :: dl_x |
---|
[5037] | 709 | REAL(dp) :: dl_x2 |
---|
| 710 | REAL(dp) :: dl_x3 |
---|
| 711 | REAL(dp) :: dl_dy |
---|
[13369] | 712 | REAL(dp) :: dl_y |
---|
[5037] | 713 | REAL(dp) :: dl_y2 |
---|
| 714 | REAL(dp) :: dl_y3 |
---|
[13369] | 715 | |
---|
[5037] | 716 | ! loop indices |
---|
[13369] | 717 | INTEGER(i4) :: ii |
---|
| 718 | INTEGER(i4) :: ji |
---|
[5037] | 719 | INTEGER(i4) :: jj |
---|
| 720 | !---------------------------------------------------------------- |
---|
[13369] | 721 | |
---|
[5037] | 722 | IF( ld_even(jp_I) )THEN |
---|
| 723 | dl_dx=1./REAL(id_rho(jp_I)-1) |
---|
| 724 | ELSE ! odd refinement |
---|
| 725 | dl_dx=1./REAL(id_rho(jp_I)) |
---|
| 726 | ENDIF |
---|
| 727 | |
---|
| 728 | IF( ld_even(jp_J) )THEN |
---|
| 729 | dl_dy=1./REAL(id_rho(jp_J)-1) |
---|
| 730 | ELSE ! odd refinement |
---|
| 731 | dl_dy=1./REAL(id_rho(jp_J)) |
---|
| 732 | ENDIF |
---|
| 733 | |
---|
| 734 | ii=0 |
---|
| 735 | DO jj=1,id_rho(jp_J)+1 |
---|
| 736 | |
---|
| 737 | IF( ld_even(jp_J) )THEN |
---|
[13369] | 738 | dl_y=(jj-1)*dl_dy - dl_dy*0.5 |
---|
[5037] | 739 | ELSE ! odd refinement |
---|
[13369] | 740 | dl_y=(jj-1)*dl_dy |
---|
[5037] | 741 | ENDIF |
---|
| 742 | dl_y2=dl_y*dl_y |
---|
| 743 | dl_y3=dl_y2*dl_y |
---|
| 744 | |
---|
| 745 | DO ji=1,id_rho(jp_I)+1 |
---|
| 746 | |
---|
| 747 | ! iter |
---|
| 748 | ii=ii+1 |
---|
| 749 | |
---|
| 750 | IF( ld_even(jp_I) )THEN |
---|
[13369] | 751 | dl_x=(ji-1)*dl_dx - dl_dx*0.5 |
---|
[5037] | 752 | ELSE ! odd refinement |
---|
[13369] | 753 | dl_x=(ji-1)*dl_dx |
---|
[5037] | 754 | ENDIF |
---|
| 755 | dl_x2=dl_x*dl_x |
---|
| 756 | dl_x3=dl_x2*dl_x |
---|
| 757 | |
---|
| 758 | dd_weight(:,ii)=(/1._dp, dl_x , dl_x2 , dl_x3 , & |
---|
| 759 | & dl_y , dl_x*dl_y , dl_x2*dl_y , dl_x3*dl_y , & |
---|
| 760 | & dl_y2, dl_x*dl_y2, dl_x2*dl_y2, dl_x3*dl_y2, & |
---|
| 761 | & dl_y3, dl_x*dl_y3, dl_x2*dl_y3, dl_x3*dl_y3 /) |
---|
| 762 | |
---|
| 763 | ENDDO |
---|
| 764 | ENDDO |
---|
| 765 | |
---|
| 766 | END SUBROUTINE interp_cubic__get_weight2D |
---|
[12080] | 767 | !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 768 | SUBROUTINE interp_cubic__get_weight1D(dd_weight, & |
---|
| 769 | & id_rho, ld_even) |
---|
[5037] | 770 | !------------------------------------------------------------------- |
---|
| 771 | !> @brief |
---|
[13369] | 772 | !> This subroutine compute interpoaltion weight for 1D array. |
---|
| 773 | !> |
---|
[5037] | 774 | !> @author J.Paul |
---|
[5609] | 775 | !> @date September, 2014 - Initial Version |
---|
[5037] | 776 | !> |
---|
| 777 | !> @param[in] dd_weight interpolation weight of 1D array |
---|
| 778 | !> @param[in] ld_even even refinment or not |
---|
[13369] | 779 | !> @param[in] id_rho refinement factor |
---|
[5037] | 780 | !------------------------------------------------------------------- |
---|
[12080] | 781 | |
---|
[5037] | 782 | IMPLICIT NONE |
---|
[12080] | 783 | |
---|
[5037] | 784 | ! Argument |
---|
| 785 | REAL(dp) , DIMENSION(:,:), INTENT(INOUT) :: dd_weight |
---|
| 786 | INTEGER(I4) , INTENT(IN ) :: id_rho |
---|
| 787 | LOGICAL , INTENT(IN ) :: ld_even |
---|
[12080] | 788 | |
---|
[5037] | 789 | ! local variable |
---|
| 790 | REAL(dp) :: dl_dx |
---|
[13369] | 791 | REAL(dp) :: dl_x |
---|
[5037] | 792 | REAL(dp) :: dl_x2 |
---|
| 793 | REAL(dp) :: dl_x3 |
---|
[12080] | 794 | |
---|
[5037] | 795 | ! loop indices |
---|
[13369] | 796 | INTEGER(i4) :: ji |
---|
[5037] | 797 | !---------------------------------------------------------------- |
---|
[13369] | 798 | |
---|
[5037] | 799 | IF( ld_even )THEN |
---|
| 800 | dl_dx=1./REAL(id_rho-1) |
---|
| 801 | ELSE ! odd refinement |
---|
| 802 | dl_dx=1./REAL(id_rho) |
---|
| 803 | ENDIF |
---|
| 804 | |
---|
| 805 | DO ji=1,id_rho+1 |
---|
| 806 | IF( ld_even )THEN |
---|
[13369] | 807 | dl_x=(ji-1)*dl_dx - dl_dx*0.5 |
---|
[5037] | 808 | ELSE ! odd refinement |
---|
[13369] | 809 | dl_x=(ji-1)*dl_dx |
---|
[5037] | 810 | ENDIF |
---|
| 811 | dl_x2=dl_x*dl_x |
---|
| 812 | dl_x3=dl_x2*dl_x |
---|
| 813 | |
---|
| 814 | dd_weight(:,ji)=(/1._dp, dl_x, dl_x2, dl_x3 /) |
---|
| 815 | ENDDO |
---|
| 816 | |
---|
| 817 | END SUBROUTINE interp_cubic__get_weight1D |
---|
[12080] | 818 | !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
[5037] | 819 | END MODULE interp_cubic |
---|