remap_bilinear_reduced.f 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. C****
  2. C *****************************
  3. C * OASIS MODULE - LEVEL ? *
  4. C * ------------- ------- *
  5. C *****************************
  6. C
  7. C**** remap_bilinear_reduced - calculate reduced grid bilinear remapping
  8. C
  9. C Purpose:
  10. C -------
  11. C Adaptation of SCRIP 1.4 remap_bilinear module to calculate
  12. C bilinear remapping for reduced grids.
  13. C
  14. C** Interface:
  15. C ---------
  16. C *CALL* *remap_bilin_reduced*
  17. C
  18. C Input:
  19. C -----
  20. C
  21. C Output:
  22. C ------
  23. C
  24. C History:
  25. C -------
  26. C Version Programmer Date Description
  27. C ------- ---------- ---- -----------
  28. C 2.5 D. Declat 2002/07 created
  29. C 2.5 S. Valcke 2002/09 modified
  30. C
  31. C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  32. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  33. !
  34. ! this module contains necessary routines for performing an
  35. ! bilinear interpolation on reduced grids.
  36. !
  37. !-----------------------------------------------------------------------
  38. !
  39. ! CVS:$Id: remap_bilinear_reduced.f 2826 2010-12-10 11:14:21Z valcke $
  40. !
  41. ! Copyright (c) 1997, 1998 the Regents of the University of
  42. ! California.
  43. !
  44. ! This software and ancillary information (herein called software)
  45. ! called SCRIP is made available under the terms described here.
  46. ! The software has been approved for release with associated
  47. ! LA-CC Number 98-45.
  48. !
  49. ! Unless otherwise indicated, this software has been authored
  50. ! by an employee or employees of the University of California,
  51. ! operator of the Los Alamos National Laboratory under Contract
  52. ! No. W-7405-ENG-36 with the U.S. Department of Energy. The U.S.
  53. ! Government has rights to use, reproduce, and distribute this
  54. ! software. The public may copy and use this software without
  55. ! charge, provided that this Notice and any statement of authorship
  56. ! are reproduced on all copies. Neither the Government nor the
  57. ! University makes any warranty, express or implied, or assumes
  58. ! any liability or responsibility for the use of this software.
  59. !
  60. ! If software is modified to produce derivative works, such modified
  61. ! software should be clearly marked, so as not to confuse it with
  62. ! the version available from Los Alamos National Laboratory.
  63. !
  64. !***********************************************************************
  65. module remap_bilinear_reduced
  66. !-----------------------------------------------------------------------
  67. use kinds_mod ! defines common data types
  68. use constants ! defines common constants
  69. use grids ! module containing grid info
  70. use remap_vars ! module containing remap info
  71. USE mod_oasis_flush
  72. implicit none
  73. !-----------------------------------------------------------------------
  74. integer (kind=int_kind), parameter ::
  75. & max_iter = 100 ! max iteration count for i,j iteration
  76. real (kind=dbl_kind), parameter ::
  77. & converge = 1.e-10_dbl_kind ! convergence criterion
  78. !***********************************************************************
  79. contains
  80. !***********************************************************************
  81. subroutine remap_bilin_reduced (lextrapdone)
  82. !-----------------------------------------------------------------------
  83. !
  84. ! this routine computes the weights for a bilinear interpolation.
  85. !
  86. !-----------------------------------------------------------------------
  87. LOGICAL ::
  88. & lextrapdone ! logical, true if EXTRAP done on field
  89. LOGICAL :: ll_nnei ! true (default) if extra search is done
  90. !-----------------------------------------------------------------------
  91. !
  92. ! local variables
  93. !
  94. !-----------------------------------------------------------------------
  95. integer (kind=int_kind) :: n, icount, i,
  96. & dst_add, ! destination address
  97. & iter, ! iteration counter
  98. & nmap ! index of current map being computed
  99. integer (kind=int_kind), dimension(4) ::
  100. & src_add ! address for the four source points
  101. real (kind=dbl_kind), dimension(4) ::
  102. & src_lats, ! latitudes of four bilinear corners
  103. & src_lons, ! longitudes of four bilinear corners
  104. & wgts ! bilinear weights for four corners
  105. real (kind=dbl_kind) ::
  106. & plat, plon, ! lat/lon coords of destination point
  107. & iguess, jguess, ! current guess for bilinear coordinate
  108. & deli, delj, ! corrections to i,j
  109. & dth1, dth2, dth3, ! some latitude differences
  110. & dph1, dph2, dph3, ! some longitude differences
  111. & dthp, dphp, ! difference between point and sw corner
  112. & mat1, mat2, mat3, mat4, ! matrix elements
  113. & determinant, ! matrix determinant
  114. & sum_wgts ! sum of weights for normalization
  115. real (kind=dbl_kind) ::
  116. & coslat_dst, sinlat_dst, coslon_dst, sinlon_dst,
  117. & dist_min, distance, ! for computing dist-weighted avg
  118. & src_latsnn, arg
  119. integer (kind=int_kind) :: min_add, max_add, srch_add, src_addnn
  120. !-----------------------------------------------------------------------
  121. !
  122. ! compute mappings from grid1 to grid2
  123. !
  124. !-----------------------------------------------------------------------
  125. !
  126. IF (nlogprt .GE. 2) THEN
  127. WRITE (UNIT = nulou,FMT = *)' '
  128. WRITE (UNIT = nulou,FMT = *)
  129. & 'Entering routine remap_bilin_reduced'
  130. CALL OASIS_FLUSH_SCRIP(nulou)
  131. ENDIF
  132. !
  133. ll_nnei = .true.
  134. nmap = 1
  135. if (grid1_rank /= 2) then
  136. stop 'Can not do bilinear interpolation when grid_rank /= 2'
  137. endif
  138. !***
  139. !*** loop over destination grid
  140. !***
  141. grid_loop1: do dst_add = 1, grid2_size
  142. if (.not. grid2_mask(dst_add)) cycle grid_loop1
  143. plat = grid2_center_lat(dst_add)
  144. plon = grid2_center_lon(dst_add)
  145. !***
  146. !*** find nearest square of grid points on source grid
  147. !***
  148. call grid_search_bilin_rd(src_add, src_lats, src_lons,
  149. & min_add, max_add,
  150. & plat, plon, grid1_dims,
  151. & grid1_center_lat, grid1_center_lon,
  152. & lextrapdone)
  153. if (src_add(1) > 0) THEN
  154. !***
  155. !*** if the 4 surrounding points have been found and are
  156. !*** non-masked, do bilinear interpolation
  157. !***
  158. grid2_frac(dst_add) = one
  159. !***
  160. !*** iterate to find i,j for bilinear approximation
  161. !***
  162. dth1 = src_lats(2) - src_lats(1)
  163. dth2 = src_lats(4) - src_lats(1)
  164. dth3 = src_lats(3) - src_lats(2) - dth2
  165. dph1 = src_lons(2) - src_lons(1)
  166. dph2 = src_lons(4) - src_lons(1)
  167. dph3 = src_lons(3) - src_lons(2)
  168. if (dph1 > three*pih) dph1 = dph1 - pi2
  169. if (dph2 > three*pih) dph2 = dph2 - pi2
  170. if (dph3 > three*pih) dph3 = dph3 - pi2
  171. if (dph1 < -three*pih) dph1 = dph1 + pi2
  172. if (dph2 < -three*pih) dph2 = dph2 + pi2
  173. if (dph3 < -three*pih) dph3 = dph3 + pi2
  174. dph3 = dph3 - dph2
  175. iguess = half
  176. jguess = half
  177. iter_loop1: do iter=1,max_iter
  178. dthp = plat - src_lats(1) - dth1*iguess -
  179. & dth2*jguess - dth3*iguess*jguess
  180. dphp = plon - src_lons(1)
  181. if (dphp > three*pih) dphp = dphp - pi2
  182. if (dphp < -three*pih) dphp = dphp + pi2
  183. dphp = dphp - dph1*iguess - dph2*jguess -
  184. & dph3*iguess*jguess
  185. mat1 = dth1 + dth3*jguess
  186. mat2 = dth2 + dth3*iguess
  187. mat3 = dph1 + dph3*jguess
  188. mat4 = dph2 + dph3*iguess
  189. determinant = mat1*mat4 - mat2*mat3
  190. deli = (dthp*mat4 - mat2*dphp)/determinant
  191. delj = (mat1*dphp - dthp*mat3)/determinant
  192. if (abs(deli) < converge .and.
  193. & abs(delj) < converge) exit iter_loop1
  194. iguess = iguess + deli
  195. jguess = jguess + delj
  196. end do iter_loop1
  197. if (iter <= max_iter) then
  198. !***
  199. !*** successfully found i,j - compute weights
  200. !***
  201. wgts(1) = (one-iguess)*(one-jguess)
  202. wgts(2) = iguess*(one-jguess)
  203. wgts(3) = iguess*jguess
  204. wgts(4) = (one-iguess)*jguess
  205. call store_link_bilin(dst_add, src_add, wgts, nmap)
  206. else
  207. write(nulou,*) 'Point coords: ',plat,plon
  208. write(nulou,*) 'Dest grid lats: ',src_lats
  209. write(nulou,*) 'Dest grid lons: ',src_lons
  210. write(nulou,*) 'Dest grid addresses: ',src_add
  211. write(nulou,*) 'Current i,j : ',iguess, jguess
  212. write(nulou,*)
  213. & 'Iteration for i,j exceed max iteration count'
  214. stop
  215. endif
  216. else if (src_add(1) < 0) THEN
  217. !***
  218. !*** We are in the first or last bin or at least one of the 4
  219. !*** neighbours was masked. Do distance-weighted average using
  220. !*** the non-masked points among the 4 closest ones.
  221. IF (nlogprt .eq. 2) then
  222. WRITE(nulou,*) ' '
  223. WRITE(nulou,*)
  224. & 'WARNING: Cannot make bilinear interpolation for target point'
  225. & ,dst_add
  226. WRITE(nulou,*)
  227. & 'Using non-masked points among 4 nearest neighbors.'
  228. CALL OASIS_FLUSH_SCRIP(nulou)
  229. ENDIF
  230. !***
  231. !*** Find the 4 closest points
  232. !***
  233. coslat_dst = cos(plat)
  234. sinlat_dst = sin(plat)
  235. coslon_dst = cos(plon)
  236. sinlon_dst = sin(plon)
  237. src_add = 0
  238. dist_min = bignum
  239. src_lats = bignum
  240. IF (min_add == 0) min_add = 1
  241. IF (max_add > grid1_size) max_add = grid1_size
  242. do srch_add = min_add,max_add
  243. arg = coslat_dst*cos(grid1_center_lat(srch_add))*
  244. & (coslon_dst*cos(grid1_center_lon(srch_add)) +
  245. & sinlon_dst*sin(grid1_center_lon(srch_add)))+
  246. & sinlat_dst*sin(grid1_center_lat(srch_add))
  247. IF (arg < -1.0d0) THEN
  248. arg = -1.0d0
  249. ELSE IF (arg > 1.0d0) THEN
  250. arg = 1.0d0
  251. END IF
  252. distance=acos(arg)
  253. if (distance < dist_min) then
  254. sort_loop: do n=1,4
  255. if (distance < src_lats(n)) then
  256. do i=4,n+1,-1
  257. src_add (i) = src_add (i-1)
  258. src_lats(i) = src_lats(i-1)
  259. end do
  260. src_add (n) = srch_add
  261. src_lats(n) = distance
  262. dist_min = src_lats(4)
  263. exit sort_loop
  264. endif
  265. end do sort_loop
  266. endif
  267. end do
  268. src_lons = one/(src_lats + tiny)
  269. distance = sum(src_lons)
  270. src_lats = src_lons/distance
  271. !***
  272. !*** Among 4 closest points, keep only the non-masked ones
  273. !***
  274. icount = 0
  275. do n=1,4
  276. if (grid1_mask(src_add(n)) .or.
  277. & (.not. grid1_mask(src_add(n)) .and. lextrapdone)) then
  278. icount = icount + 1
  279. else
  280. src_lats(n) = zero
  281. endif
  282. end do
  283. if (icount > 0) then
  284. !*** renormalize weights
  285. sum_wgts = sum(src_lats)
  286. wgts(1) = src_lats(1)/sum_wgts
  287. wgts(2) = src_lats(2)/sum_wgts
  288. wgts(3) = src_lats(3)/sum_wgts
  289. wgts(4) = src_lats(4)/sum_wgts
  290. grid2_frac(dst_add) = one
  291. call store_link_bilin(dst_add, src_add, wgts, nmap)
  292. ELSE
  293. IF (ll_nnei .eqv. .true. ) then
  294. IF (nlogprt .ge. 2) THEN
  295. WRITE(nulou,*) ' '
  296. WRITE(nulou,*)
  297. & 'All 4 surrounding source grid points are masked'
  298. WRITE(nulou,*) 'for target point ',dst_add
  299. WRITE(nulou,*) 'with longitude and latitude',
  300. & plon, plat
  301. WRITE(nulou,*)
  302. & 'Using the nearest non-masked neighbour.'
  303. CALL OASIS_FLUSH_SCRIP(nulou)
  304. ENDIF
  305. src_latsnn = bignum
  306. !cdir novector
  307. do srch_add = min_add,max_add
  308. if (grid1_mask(srch_add) .or.
  309. & (.not. grid1_mask(srch_add) .and. lextrapdone)) THEN
  310. arg = coslat_dst*cos(grid1_center_lat(srch_add))*
  311. & (coslon_dst*cos(grid1_center_lon(srch_add)) +
  312. & sinlon_dst*sin(grid1_center_lon(srch_add)))+
  313. & sinlat_dst*sin(grid1_center_lat(srch_add))
  314. IF (arg < -1.0d0) THEN
  315. arg = -1.0d0
  316. ELSE IF (arg > 1.0d0) THEN
  317. arg = 1.0d0
  318. END IF
  319. distance=acos(arg)
  320. if (distance < src_latsnn) then
  321. src_addnn = srch_add
  322. src_latsnn = distance
  323. endif
  324. endif
  325. end DO
  326. IF (nlogprt .ge. 2) THEN
  327. WRITE(nulou,*)
  328. & 'Nearest non masked neighbour is source point '
  329. & ,src_addnn
  330. WRITE(nulou,*) 'with longitude and latitude',
  331. & grid1_center_lon(src_addnn),
  332. & grid1_center_lat(src_addnn)
  333. WRITE(nulou,*) ' '
  334. CALL OASIS_FLUSH_SCRIP(nulou)
  335. ENDIF
  336. wgts(1) = 1.
  337. wgts(2) = 0.
  338. wgts(3) = 0.
  339. wgts(4) = 0.
  340. src_add(1) = src_addnn
  341. src_add(2) = 0
  342. src_add(3) = 0
  343. src_add(4) = 0
  344. grid2_frac(dst_add) = one
  345. call store_link_bilin(dst_add, src_add, wgts, nmap)
  346. endif
  347. ENDIF
  348. ENDIF
  349. end do grid_loop1
  350. !
  351. !-----------------------------------------------------------------------
  352. end subroutine remap_bilin_reduced
  353. !***********************************************************************
  354. subroutine grid_search_bilin_rd(src_add, src_lats, src_lons,
  355. & min_add, max_add,
  356. & plat, plon, src_grid_dims,
  357. & src_center_lat, src_center_lon,
  358. & lextrapdone)
  359. !-----------------------------------------------------------------------
  360. !
  361. ! this routine finds the location of the search point plat, plon
  362. ! in the source grid and returns the corners needed for a bilinear
  363. ! interpolation. The target grid is a reduced grid.
  364. !
  365. !-----------------------------------------------------------------------
  366. !-----------------------------------------------------------------------
  367. !
  368. ! output variables
  369. !
  370. !-----------------------------------------------------------------------
  371. integer (kind=int_kind), dimension(4), intent(out) ::
  372. & src_add ! address of each corner point enclosing P
  373. real (kind=dbl_kind), dimension(4), intent(out) ::
  374. & src_lats, ! latitudes of the four corner points
  375. & src_lons ! longitudes of the four corner points
  376. integer (kind=int_kind) :: min_add, max_add
  377. !-----------------------------------------------------------------------
  378. !
  379. ! input variables
  380. !
  381. !-----------------------------------------------------------------------
  382. real (kind=dbl_kind), intent(in) ::
  383. & plat, ! latitude of the search point
  384. & plon ! longitude of the search point
  385. integer (kind=int_kind), dimension(2), intent(in) ::
  386. & src_grid_dims ! size of each src grid dimension
  387. real (kind=dbl_kind), dimension(:), intent(in) ::
  388. & src_center_lat, ! latitude of each src grid center
  389. & src_center_lon ! longitude of each src grid center
  390. LOGICAL ::
  391. & lextrapdone ! logical, true if EXTRAP done on field
  392. !-----------------------------------------------------------------------
  393. !
  394. ! local variables
  395. !
  396. !-----------------------------------------------------------------------
  397. integer (kind=int_kind) :: n, next_n, srch_add, ni, ! dummy indices
  398. & nx, ny, ntotmask, ! dimensions of src grid
  399. & inter_add ! add for restricting search
  400. !
  401. integer (kind=int_kind), DIMENSION(4) :: src_bid
  402. !-----------------------------------------------------------------------
  403. !
  404. ! restrict search first using bins
  405. !
  406. !-----------------------------------------------------------------------
  407. nx = src_grid_dims(1)
  408. inter_add = 0
  409. src_add = 0
  410. min_add = size(src_center_lat) + 1
  411. max_add = 1
  412. if (plat >= bin_lats_r(1,1)) then
  413. min_add = 0
  414. max_add = bin_addr1_r(4,1)
  415. inter_add = bin_addr1_r(3,1)
  416. else if (plat <= bin_lats_r(1,num_srch_red)) then
  417. max_add = nx + 1
  418. min_add = bin_addr1_r(1,num_srch_red)
  419. inter_add = bin_addr1_r(3,num_srch_red)
  420. else
  421. srch_loopred: do n=1,num_srch_red
  422. if (plat <= bin_lats_r(1,n)
  423. & .and. plat >= bin_lats_r(2,n)) then
  424. min_add = bin_addr1_r(1,n)
  425. max_add = bin_addr1_r(4,n)
  426. inter_add = bin_addr1_r(3,n)
  427. exit srch_loopred
  428. endif
  429. end DO srch_loopred
  430. ENDIF
  431. !-----------------------------------------------------------------------
  432. !
  433. ! now perform a more detailed search
  434. !
  435. !-----------------------------------------------------------------------
  436. if (min_add .ne. 0 .and. max_add .ne. nx+1) THEN
  437. !*** The concerned bins are not the top north or south ones.
  438. !*** We should be able to find the four corners
  439. !*** for the bilinear interpolation.
  440. IF ( plon <= src_center_lon(min_add) ) THEN
  441. src_add(1) = inter_add-1
  442. src_add(2) = min_add
  443. ELSE IF ( plon > src_center_lon(inter_add-1) ) then
  444. src_add(1) = inter_add-1
  445. src_add(2) = min_add
  446. else
  447. srch_loop2: do srch_add = min_add, inter_add-2
  448. if ( (plon > src_center_lon(srch_add)) .and.
  449. & (plon <= src_center_lon(srch_add+1)) )then
  450. src_add(1) = srch_add
  451. src_add(2) = srch_add+1
  452. exit srch_loop2
  453. endif
  454. end do srch_loop2
  455. ENDIF
  456. IF ( plon <= src_center_lon(inter_add) ) THEN
  457. src_add(3) = max_add
  458. src_add(4) = inter_add
  459. ELSE IF ( plon >= src_center_lon(max_add) ) then
  460. src_add(3) = max_add
  461. src_add(4) = inter_add
  462. else
  463. srch_loop3: do srch_add = inter_add, max_add
  464. if ( (plon >= src_center_lon(srch_add)) .and.
  465. & (plon <= src_center_lon(srch_add+1)) )then
  466. src_add(3) = srch_add
  467. src_add(4) = srch_add+1
  468. exit srch_loop3
  469. endif
  470. enddo srch_loop3
  471. ENDIF
  472. src_lats(1) = src_center_lat(src_add(3))
  473. src_lats(2) = src_center_lat(src_add(4))
  474. src_lats(3) = src_center_lat(src_add(2))
  475. src_lats(4) = src_center_lat(src_add(1))
  476. src_lons(1) = src_center_lon(src_add(3))
  477. src_lons(2) = src_center_lon(src_add(4))
  478. src_lons(3) = src_center_lon(src_add(2))
  479. src_lons(4) = src_center_lon(src_add(1))
  480. src_bid=src_add
  481. src_add(1) = src_bid(3)
  482. src_add(2) = src_bid(4)
  483. src_add(3) = src_bid(2)
  484. src_add(4) = src_bid(1)
  485. ! Check if one point is masked; IF so, nearest-neighbour
  486. ! interpolation will be used
  487. ntotmask = 0
  488. do ni=1,4
  489. if (.not. grid1_mask(src_add(ni)).and.
  490. & .not. lextrapdone)
  491. & ntotmask = ntotmask + 1
  492. end DO
  493. IF (ntotmask .gt. 0) src_add(1) = -src_add(1)
  494. ELSE
  495. !*** We are in the first or last bin. Put src_add = -1 so that
  496. !*** distance-weighted average of the 4 non-masked closest points
  497. !*** is done in calling routine.
  498. src_add = -1
  499. ENDIF
  500. !-----------------------------------------------------------------------
  501. end subroutine grid_search_bilin_rd
  502. !***********************************************************************
  503. subroutine store_link_bilin(dst_add, src_add, weights, nmap)
  504. !-----------------------------------------------------------------------
  505. !
  506. ! this routine stores the address and weight for four links
  507. ! associated with one destination point in the appropriate address
  508. ! and weight arrays and resizes those arrays if necessary.
  509. !
  510. !-----------------------------------------------------------------------
  511. !-----------------------------------------------------------------------
  512. !
  513. ! input variables
  514. !
  515. !-----------------------------------------------------------------------
  516. integer (kind=int_kind), intent(in) ::
  517. & dst_add, ! address on destination grid
  518. & nmap ! identifies which direction for mapping
  519. integer (kind=int_kind), dimension(4), intent(in) ::
  520. & src_add ! addresses on source grid
  521. real (kind=dbl_kind), dimension(4), intent(in) ::
  522. & weights ! array of remapping weights for these links
  523. !-----------------------------------------------------------------------
  524. !
  525. ! local variables
  526. !
  527. !-----------------------------------------------------------------------
  528. integer (kind=int_kind) :: n, ! dummy index
  529. & num_links_old ! placeholder for old link number
  530. !-----------------------------------------------------------------------
  531. !
  532. ! increment number of links and check to see if remap arrays need
  533. ! to be increased to accomodate the new link. then store the
  534. ! link.
  535. !
  536. !-----------------------------------------------------------------------
  537. select case (nmap)
  538. case(1)
  539. num_links_old = num_links_map1
  540. num_links_map1 = num_links_old + 4
  541. if (num_links_map1 > max_links_map1)
  542. & call resize_remap_vars(1,resize_increment)
  543. do n=1,4
  544. grid1_add_map1(num_links_old+n) = src_add(n)
  545. grid2_add_map1(num_links_old+n) = dst_add
  546. wts_map1 (1,num_links_old+n) = weights(n)
  547. end do
  548. case(2)
  549. num_links_old = num_links_map2
  550. num_links_map2 = num_links_old + 4
  551. if (num_links_map2 > max_links_map2)
  552. & call resize_remap_vars(2,resize_increment)
  553. do n=1,4
  554. grid1_add_map2(num_links_old+n) = dst_add
  555. grid2_add_map2(num_links_old+n) = src_add(n)
  556. wts_map2 (1,num_links_old+n) = weights(n)
  557. end do
  558. end select
  559. !-----------------------------------------------------------------------
  560. end subroutine store_link_bilin
  561. !***********************************************************************
  562. end module remap_bilinear_reduced
  563. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!