scrip.f 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  2. !
  3. ! This routine is the driver for computing the addresses and weights
  4. ! for interpolating between two grids on a sphere.
  5. !
  6. !-----------------------------------------------------------------------
  7. !
  8. ! CVS:$Id: scrip.f,v 1.6 2001/08/21 21:06:44 pwjones Exp $
  9. !
  10. ! Copyright (c) 1997, 1998 the Regents of the University of
  11. ! California.
  12. !
  13. ! This software and ancillary information (herein called software)
  14. ! called SCRIP is made available under the terms described here.
  15. ! The software has been approved for release with associated
  16. ! LA-CC Number 98-45.
  17. !
  18. ! Unless otherwise indicated, this software has been authored
  19. ! by an employee or employees of the University of California,
  20. ! operator of the Los Alamos National Laboratory under Contract
  21. ! No. W-7405-ENG-36 with the U.S. Department of Energy. The U.S.
  22. ! Government has rights to use, reproduce, and distribute this
  23. ! software. The public may copy and use this software without
  24. ! charge, provided that this Notice and any statement of authorship
  25. ! are reproduced on all copies. Neither the Government nor the
  26. ! University makes any warranty, express or implied, or assumes
  27. ! any liability or responsibility for the use of this software.
  28. !
  29. ! If software is modified to produce derivative works, such modified
  30. ! software should be clearly marked, so as not to confuse it with
  31. ! the version available from Los Alamos National Laboratory.
  32. !
  33. !***********************************************************************
  34. program scrip
  35. !-----------------------------------------------------------------------
  36. use kinds_mod ! module defining data types
  37. use constants ! module for common constants
  38. use iounits ! I/O unit manager
  39. use timers ! CPU timers
  40. use grids ! module with grid information
  41. use remap_vars ! common remapping variables
  42. use remap_conservative ! routines for conservative remap
  43. use remap_distance_weight ! routines for dist-weight remap
  44. use remap_bilinear ! routines for bilinear interp
  45. use remap_bicubic ! routines for bicubic interp
  46. use remap_write ! routines for remap output
  47. implicit none
  48. !-----------------------------------------------------------------------
  49. !
  50. ! input namelist variables
  51. !
  52. !-----------------------------------------------------------------------
  53. character (char_len) ::
  54. & grid1_file, ! filename of grid file containing grid1
  55. & grid2_file, ! filename of grid file containing grid2
  56. & interp_file1, ! filename for output remap data (map1)
  57. & interp_file2, ! filename for output remap data (map2)
  58. & map1_name, ! name for mapping from grid1 to grid2
  59. & map2_name, ! name for mapping from grid2 to grid1
  60. & map_method, ! choice for mapping method
  61. & normalize_opt,! option for normalizing weights
  62. & output_opt ! option for output conventions
  63. integer (kind=int_kind) ::
  64. & nmap ! number of mappings to compute (1 or 2)
  65. namelist /remap_inputs/ grid1_file, grid2_file,
  66. & interp_file1, interp_file2,
  67. & map1_name, map2_name, num_maps,
  68. & luse_grid1_area, luse_grid2_area,
  69. & map_method, normalize_opt, output_opt,
  70. & restrict_type, num_srch_bins
  71. !-----------------------------------------------------------------------
  72. !
  73. ! local variables
  74. !
  75. !-----------------------------------------------------------------------
  76. integer (kind=int_kind) :: n, ! dummy counter
  77. & iunit ! unit number for namelist file
  78. !-----------------------------------------------------------------------
  79. !
  80. ! initialize timers
  81. !
  82. !-----------------------------------------------------------------------
  83. call timers_init
  84. do n=1,max_timers
  85. call timer_clear(n)
  86. end do
  87. !-----------------------------------------------------------------------
  88. !
  89. ! read input namelist
  90. !
  91. !-----------------------------------------------------------------------
  92. grid1_file = 'unknown'
  93. grid2_file = 'unknown'
  94. interp_file1 = 'unknown'
  95. interp_file2 = 'unknown'
  96. map1_name = 'unknown'
  97. map2_name = 'unknown'
  98. luse_grid1_area = .false.
  99. luse_grid2_area = .false.
  100. num_maps = 2
  101. map_type = 1
  102. normalize_opt = 'fracarea'
  103. output_opt = 'scrip'
  104. restrict_type = 'latitude'
  105. num_srch_bins = 900
  106. call get_unit(iunit)
  107. open(iunit, file='scrip_in', status='old', form='formatted')
  108. read(iunit, nml=remap_inputs)
  109. call release_unit(iunit)
  110. select case(map_method)
  111. case ('conservative')
  112. map_type = map_type_conserv
  113. luse_grid_centers = .false.
  114. case ('bilinear')
  115. map_type = map_type_bilinear
  116. luse_grid_centers = .true.
  117. case ('bicubic')
  118. map_type = map_type_bicubic
  119. luse_grid_centers = .true.
  120. case ('distwgt')
  121. map_type = map_type_distwgt
  122. luse_grid_centers = .true.
  123. case default
  124. stop 'unknown mapping method'
  125. end select
  126. select case(normalize_opt(1:4))
  127. case ('none')
  128. norm_opt = norm_opt_none
  129. case ('frac')
  130. norm_opt = norm_opt_frcarea
  131. case ('dest')
  132. norm_opt = norm_opt_dstarea
  133. case default
  134. stop 'unknown normalization option'
  135. end select
  136. !-----------------------------------------------------------------------
  137. !
  138. ! initialize grid information for both grids
  139. !
  140. !-----------------------------------------------------------------------
  141. call grid_init(grid1_file, grid2_file)
  142. write(stdout, *) ' Computing remappings between: ',grid1_name
  143. write(stdout, *) ' and ',grid2_name
  144. !-----------------------------------------------------------------------
  145. !
  146. ! initialize some remapping variables.
  147. !
  148. !-----------------------------------------------------------------------
  149. call init_remap_vars
  150. !-----------------------------------------------------------------------
  151. !
  152. ! call appropriate interpolation setup routine based on type of
  153. ! remapping requested.
  154. !
  155. !-----------------------------------------------------------------------
  156. select case(map_type)
  157. case(map_type_conserv)
  158. call remap_conserv
  159. case(map_type_bilinear)
  160. call remap_bilin
  161. case(map_type_distwgt)
  162. call remap_distwgt
  163. case(map_type_bicubic)
  164. call remap_bicub
  165. case default
  166. stop 'Invalid Map Type'
  167. end select
  168. !-----------------------------------------------------------------------
  169. !
  170. ! reduce size of remapping arrays and then write remapping info
  171. ! to a file.
  172. !
  173. !-----------------------------------------------------------------------
  174. if (num_links_map1 /= max_links_map1) then
  175. call resize_remap_vars(1, num_links_map1-max_links_map1)
  176. endif
  177. if ((num_maps > 1) .and. (num_links_map2 /= max_links_map2)) then
  178. call resize_remap_vars(2, num_links_map2-max_links_map2)
  179. endif
  180. call write_remap(map1_name, map2_name,
  181. & interp_file1, interp_file2, output_opt)
  182. !-----------------------------------------------------------------------
  183. end program scrip
  184. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!