README 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. nocsSCRIP v1.1 03/11/2010
  2. -------------------------
  3. Author: NOCS NEMO Team
  4. Contacts: Steven Alderson (sga@noc.soton.ac.uk)
  5. Andrew Coward (acc@noc.soton.ac.uk)
  6. Disclaimer
  7. This directory contains software for generating and manipulating interpolation
  8. weights for use with the Interpolation On the Fly (IOF) option in NEMO
  9. v3 onwards. The utilities rely heavily on the Spherical Coordinate Remapping
  10. and Interpolation Package (SCRIP) which is freely available from Los Alamos
  11. (see copyright file). We make no claim to authorship of those parts of the
  12. SCRIP package we have used and included with this distribution.
  13. Unless otherwise indicated, all other software has been authored by an
  14. employee or employees of the National Oceanography Centre, Southampton, UK
  15. (NOCS). NOCS operates as a collaboration between the Natural Environment
  16. Research Council (NERC) and the University of Southampton. The public may
  17. copy and use this software without charge, provided that this Notice and any
  18. statement of authorship are reproduced on all copies. Neither NERC nor the
  19. University makes any warranty, express or implied, or assumes any liability
  20. or responsibility for the use of this software.
  21. Introduction
  22. The IOF option enables forced ocean runs without the need to provide surface
  23. boundary data on the nemo grid. Atmospheric data are kept on their original
  24. grid(s) which typically have a coarser resolution than the ocean grid. IOF
  25. supports multiple source (atmospheric) grids and two interpolation methods
  26. (bilinear and bicubic). Different combinations of source grid and method can
  27. be selected for each variable. IOF is also compatible with AGRIF; allowing
  28. AGRIF nests to be used without the need to provide separate forcing data
  29. (only a separate set of weights fields). Operational details are provided
  30. in the SBC chapter of the NEMO reference manual.
  31. Please note that the methods described here assume that the forcing datasets
  32. are unmasked. Where the original sources are masked it is the users'
  33. responsibility to ensure that an unmasked set is produced on the source
  34. grid with appropriate oceanic values in previously masked locations. This
  35. is particularly important for atmospheric variables which experience step
  36. changes at the land-sea boundary. For these, care must be taken to avoid
  37. contaminating oceanic values.
  38. The software is divided into several sub-directories:
  39. ./
  40. |
  41. +-------------+--------------+--------------+
  42. SCRIP1.4 nocsutil src bin
  43. SCRIP1.4 contains the unmodified copy (apart from compression of two sample netcdf
  44. files) of SCRIP version 1.4 from Los Alamos.
  45. (http://climate.lanl.gov/Software/SCRIP).
  46. The bin directory contains python script freeform.py.
  47. This is run to reformat the code for use within the NEMO 3.3 fcm framework.
  48. It creates and populates a directory called 'src' with copied and modified versions
  49. of the SCRIP library routines (and derived programs from the nocsutil directory).
  50. Changes are described in the src/CHANGES file.
  51. This script has already been run and only needs to be re-executed if SCRIP is updated.
  52. The src directory also contains the three programs used to generate a weights file.
  53. The three programs are:
  54. scripgrid.exe (scripgrid.F90) which creates two grid description files suitable for
  55. input to the scrip package.
  56. scrip.exe (scrip.F90) which takes these descriptions and generates the required
  57. weights in the standard SCRIP format. This program is a version of the SCRIP
  58. program: scrip.f which has been modified to accept the name of its namelist
  59. file on the command line.
  60. scripshape.exe (scripshape.F90) which takes the output from scrip and rearranges
  61. the fields into a series of 2D fields more suited for input into NEMO using
  62. the iom_get routine.
  63. All three FORTRAN90 programs read domain information from their respective
  64. netCDF input files and dynamically allocate internal storage. They are
  65. thus independent of the target configuration and have been successfully
  66. tested with both ORCA2 and ORCA025 grids. Their suitably for use with larger
  67. grids has not been tested but should only be subject to limitations of
  68. the operating system and the memory available to the processing element.
  69. A separate tar file is available containing test data.
  70. This comprises an ORCA2 coordinates file and sample DFS4.1 input field that
  71. can be used for testing. Reference weights files generated using the two
  72. example namelists provided are located in its refout subdirectory.
  73. Installation is by use of the maketools script.
  74. E.g. change to the NEMOGCM/TOOLS directory and type:
  75. ./maketools -help
  76. and, for example:
  77. ./maketools -m gfortran_linux -n WEIGHTS
  78. Example Use
  79. -----------
  80. cd data
  81. ../scripgrid.exe namelist_reshape_bilin (creates remap_data_grid.nc
  82. and remap_nemo_grid.nc)
  83. ../scrip.exe namelist_reshape_bilin (creates data_nemo_bilin.nc)
  84. ../scripshape.exe namelist_reshape_bilin (creates reshape_orca2_bilinear.nc)
  85. [Note that because the gfortran compiler does not understand the iargc function
  86. and getarg subroutine calls, command line namelist names can only be supplied if
  87. symbol ARGC is defined during compilation (eg add '#define ARGC' to the top of
  88. the relevant program). If not, the program asks for the name instead during execution.]
  89. Only the final output file is required for use with NEMO but the intermediate
  90. files can be checked against the examples in the test data (available separately).
  91. For bicubic mapping only scrip and scripshape need to be rerun (because the grid_inputs namelist
  92. entries are identical in the two namelist files, see Controls section below):
  93. ../scrip.exe namelist_reshape_bicubic (creates data_nemo_bicubic.nc)
  94. ../scripshape.exe namelist_reshape_bicubic (creates reshape_orca2_bicubic.nc)
  95. Controls
  96. --------
  97. The SCRIP derived utilities use SCRIP-style namelists to control their
  98. operation. In the example above the same named file is used for both but within that
  99. file are two separate namelists:
  100. &grid_inputs
  101. input_file = './snow_1m_TRP_1958.nc'
  102. nemo_file = 'coordinates.nc'
  103. datagrid_file = 'remap_data_grid.nc'
  104. nemogrid_file = 'remap_nemo_grid.nc'
  105. method = 'regular'
  106. input_lon = 'lon'
  107. input_lat = 'lat'
  108. nemo_lon = 'glamt'
  109. nemo_lat = 'gphit'
  110. nemo_mask = 'none'
  111. nemo_mask_value = 10
  112. input_mask = 'none'
  113. input_mask_value = 10
  114. /
  115. which is used by scripgrid, and:
  116. &remap_inputs
  117. num_maps = 1
  118. grid1_file = 'remap_data_grid.nc'
  119. grid2_file = 'remap_nemo_grid.nc'
  120. interp_file1 = 'data_nemo_bilin.nc'
  121. interp_file2 = 'nemo_data_bilin.nc'
  122. map1_name = 'data to nemo bilin Mapping'
  123. map2_name = 'nemo to data bilin Mapping'
  124. map_method = 'bilinear'
  125. normalize_opt = 'frac'
  126. output_opt = 'scrip'
  127. restrict_type = 'latitude'
  128. num_srch_bins = 90
  129. luse_grid1_area = .false.
  130. luse_grid2_area = .false.
  131. /
  132. which is used by scrip.
  133. scripshape also reads information from a namelist:
  134. &shape_inputs
  135. interp_file = 'data_nemo_bilin.nc'
  136. output_file = 'weights_bilin.nc'
  137. ew_wrap = 0
  138. /
  139. scripgrid.exe
  140. -------------
  141. scripgrid accesses the named files and coordinate data in order to produce
  142. the grid centre and corner locations required by scrip. In the example given,
  143. a file called 'coordinates.nc' must exist in the current directory. This is
  144. used by scripgrid as a nemo coordinates file and the correct corner
  145. locations appropriate to the named grid centres are obtained (i.e. since
  146. glamt is named, glamf and gphif will be used to provide corner coordinates).
  147. The nemo file need not be called 'coordinates.nc' (e.g. '1_coordinates.nc' instead),
  148. but must have longitude and latitude variables which start with the four
  149. characters 'gphi' and 'glam' respectively.
  150. "input_file" file must contain at least one variable on a grid whose axes are
  151. described by the netcdf coordinate variables named in input_lon and input_lat.
  152. The program produces two grid description files, one corresponding to each
  153. input file, for use by the scrip program to calculate weights required to
  154. go from one to the other and back again.
  155. This step is independent of the mapping method (e.g. bilinear or bicubic)
  156. and so only one set of remap_data_grid.nc and remap_nemo_grid.nc files needs
  157. to be produced for each pair of source and destination grids.
  158. scrip.exe
  159. ---------
  160. scrip takes the output files from scripgrid and creates a file of weights
  161. to use to interpolate between the two grids described. The example given
  162. only requests 1 map (from data to nemo); setting num_maps=2 will provide
  163. the reverse weights if required.
  164. - num_maps is either 1 or 2 depending on whether the reverse
  165. transformation is required
  166. - grid1_file, grid2_file: two remap grid files are required
  167. as output by scripgrid
  168. - interp_file1, interp_file2: one or two interp_file names are
  169. then supplied; these hold the weights to convert one grid to another
  170. - map1_name, map2_name: the map_name variables are just descriptive
  171. - map_method: can be 'bilinear' or 'bicubic'
  172. - normalize_opt: should usually be 'frac' or else the user needs to do
  173. this scaling manually (this seems to the case for fractional ice cover)
  174. - output_opt may be supplied and set to either 'scrip' or 'ncar-csm'
  175. - restrict_type: should be 'latitude' or 'latlon' in which case
  176. num_srch_bins only are used in one or two directions
  177. - use_grid_area fields override the scrip calculation of area in
  178. case the model gets slightly different answers, but the area needs
  179. to be supplied in the input files
  180. A conservative mapping scheme exists but is not yet working with NEMO grids.
  181. See the scrip package documentation for more details of these parameters.
  182. (http://climate.lanl.gov/Software/SCRIP/SCRIPusers.pdf)
  183. scripshape.exe
  184. --------------
  185. scripshape takes the output from scrip (e.g. data_nemo_bilin.nc ) and
  186. rearranges the source and destination indices and associated weights into
  187. sets of 2D fields each spanning the nemo grid. Each set is associated with
  188. each node involved in the interpolation scheme. Thus for a bilinear mapping
  189. the weights file required by the IOF option includes the following fields:
  190. double src01(lat, lon) ; double dst01(lat, lon) ; double wgt01(lat, lon) ;
  191. double src02(lat, lon) ; double dst02(lat, lon) ; double wgt02(lat, lon) ;
  192. double src03(lat, lon) ; double dst03(lat, lon) ; double wgt03(lat, lon) ;
  193. double src04(lat, lon) ; double dst04(lat, lon) ; double wgt04(lat, lon) ;
  194. For a bicubic mapping the required fields are:
  195. double src01(lat, lon) ; double dst01(lat, lon) ; double wgt01(lat, lon) ;
  196. double src02(lat, lon) ; double dst02(lat, lon) ; double wgt02(lat, lon) ;
  197. double src03(lat, lon) ; double dst03(lat, lon) ; double wgt03(lat, lon) ;
  198. double src04(lat, lon) ; double dst04(lat, lon) ; double wgt04(lat, lon) ;
  199. double src05(lat, lon) ; double dst05(lat, lon) ; double wgt05(lat, lon) ;
  200. double src06(lat, lon) ; double dst06(lat, lon) ; double wgt06(lat, lon) ;
  201. double src07(lat, lon) ; double dst07(lat, lon) ; double wgt07(lat, lon) ;
  202. double src08(lat, lon) ; double dst08(lat, lon) ; double wgt08(lat, lon) ;
  203. double src09(lat, lon) ; double dst09(lat, lon) ; double wgt09(lat, lon) ;
  204. double src10(lat, lon) ; double dst10(lat, lon) ; double wgt10(lat, lon) ;
  205. double src11(lat, lon) ; double dst11(lat, lon) ; double wgt11(lat, lon) ;
  206. double src12(lat, lon) ; double dst12(lat, lon) ; double wgt12(lat, lon) ;
  207. double src13(lat, lon) ; double dst13(lat, lon) ; double wgt13(lat, lon) ;
  208. double src14(lat, lon) ; double dst14(lat, lon) ; double wgt14(lat, lon) ;
  209. double src15(lat, lon) ; double dst15(lat, lon) ; double wgt15(lat, lon) ;
  210. double src16(lat, lon) ; double dst16(lat, lon) ; double wgt16(lat, lon) ;
  211. This program also adds an attribute to the weights file for use by the fld_interp
  212. routine in fldread.F90. This tells the model about the east-west cyclicity of the source grid.
  213. The value needs to be supplied in the scripshape namelist via the variable ew_wrap.
  214. It should have one of the values -1, 0, 1 or 2. -1 means that the input grid is not
  215. cyclic; 0 means that it is cyclic but with no overlapping columns; and a value greater
  216. than zero represents the number of columns that overlap. In fact it only has an effect
  217. when using bicubic interpolation in which the model needs to know which additional columns
  218. have to be read in to correctly calculate gradient values.
  219. The weights file produced by scripshape is ready for use in NEMO. This file
  220. needs to by placed in the nemo working directory and needs to be named in the
  221. appropriate SBC namelist entry (e.g. namsbc_clio, namsbc_flux or namsbc_core).
  222. scripinterp.exe
  223. ---------------
  224. Take data on an input grid and interpolate to the nemo grid using the weights
  225. calculated by the scrip program.
  226. Method
  227. Two namelists are used for configuration, eg
  228. &interp_inputs
  229. input_file = "../data/wsx_av.nc"
  230. interp_file = "data_nemo_bilin.nc"
  231. input_name = "wsx"
  232. input_start = 1,1,1,1
  233. input_stride = 1,1,1,1
  234. input_stop = 0,0,0,1
  235. input_vars = 'time'
  236. /
  237. &interp_outputs
  238. output_file = "taux_1m.nc"
  239. output_mode = "create"
  240. output_dims = 'x', 'y', 'time_counter'
  241. output_scaling = "sozotaux|1.0", "time_counter|86400.0"
  242. output_name = 'sozotaux'
  243. output_lon = 'x'
  244. output_lat = 'y'
  245. output_vars = 'time_counter'
  246. output_attributes = 'time_counter|units|seconds since 1995-00-00 00:00:00',
  247. 'time_counter|calendar|noleap',
  248. 'sozotaux|units|N/m2'
  249. /
  250. This program just multiplies by weights and sums over each contributing point,
  251. and then formats the output correctly for the model.