1. summary: conservative mappings between gx3v7 and T31 2. created by: David Bailey 3. date and time: Mar 09, 2012 4. created on: bluefire 5. dataset format: nc 6. endian: n/a 7. archival copy location: /CCSM/mapping/maps 8. creation summary: The following is a deSCRIPtion of how one would produce a netcdf mapping file between gx3v4 and T31 grids. You may wish to replace these grid names in the following and then make use of copy-paste to produce grid files and/or weights. ----------- -- Setup -- ----------- Copy SCRIP code from most recent gx* directory, under /glade/proj3/csegapping/make_grids Copied SCRIP from these directories: /glade/proj3/csegapping/make_grids In grids/convert[POPT, gauss, etc.].f Edit nx, ny, grid_name, and grid_file_out. Any other edits? make In dir, make -f makefile.bluefire ----------- -- Grids -- ----------- Note: As of March 2010 we are not using the standard scrip1.4.01 version of convertPOPT, but have nonstandard code to use the ccsm_pop/cice calculation of T-grid cell center locations, and we use Keith's nonstd calculation of southern-most points. I'm getting this code from Steve Yeager. I am fixing the older version of gx3v7 as it was causing aborts in the DOCN. The diffs from the standard version are: < & grid_file_out = 'gx3v7_120309.nc' --- > & grid_file_out = 'gx3v7_090903.nc' 109,110c109 < integer (kind=int_kind) :: i, j, n, iunit, ocn_add, im1, jm1, < & jp1, jp2 --- > integer (kind=int_kind) :: i, j, n, iunit, ocn_add, im1, jm1 129c128 < real (kind=dbl_kind) :: tmplon, dxt, dyt, dlat --- > real (kind=dbl_kind) :: tmplon, dxt, dyt 205,206c204,205 < ! grid_corner_lat(1,i) = -pih + tiny < ! grid_corner_lat(2,i) = -pih + tiny --- > grid_corner_lat(1,i) = -pih + tiny > grid_corner_lat(2,i) = -pih + tiny 208,215d206 < dlat = grid_corner_lat(1,i+2*nx) - grid_corner_lat(1,i+nx) < grid_corner_lat(1,i) = grid_corner_lat(1,i+nx) - dlat < grid_corner_lat(1,i) = max(grid_corner_lat(1,i), -pih + tiny) < < dlat = grid_corner_lat(2,i+2*nx) - grid_corner_lat(2,i+nx) < grid_corner_lat(2,i) = grid_corner_lat(2,i+nx) - dlat < grid_corner_lat(2,i) = max(grid_corner_lat(2,i), -pih + tiny) < 318,327d308 < < ! j=1: linear approximation < do i=1,nx < ocn_add = i < jp1 = nx + i < jp2 = 2*nx + i < grid_center_lon(ocn_add) = grid_center_lon(jp1) < grid_center_lat(ocn_add) = two*grid_center_lat(jp1) - < & grid_center_lat(jp2) < end do Add documentation: ncatted -O -h -a Created_by,global,a,c,"`whoami`, `date`" gx3v7_120309.nc ncatted -O -h -a horiz_grid,global,a,c,"/fis/cgd/cseg/csm/inputdata/ocn/pop/gx3v7/grid/horiz_grid_20030806.ieeer8" gx3v7_120309.nc ncatted -O -h -a scrip_code,global,o,c,"/fis/cgd/cseg/csm/mapping/code/scrip1.4.01" gx3v7_120309.nc ----------- -- Scrip -- ----------- write scrip_in: cat >! scrip_in &remap_inputs num_maps = 2 grid1_file = '/fs/cgd/data0/brady/csm_pop/gx3v4/gx3v4_020513.nc' grid2_file = '/fs/cgd/csm/mapping/grids/T31.nc' interp_file1 = 'map_gx3v4_to_T31_aave_da_020513.nc' interp_file2 = 'map_T31_to_gx3v4_aave_da_020513.nc' map1_name = 'gx3v4 to T31 Mapping' map2_name = 'T31 to gx3v4 Mapping' map_method = 'conservative' normalize_opt = 'destarea' output_opt = 'ncar-csm' restrict_type = 'latlon' num_srch_bins = 10 / Note that the grid files should come from the standard CCSM location (/fs/cgd/csm/mapping/grids/) unless the grid is untested (see below for the testing procedure which is recommended at this point in time). Run scrip: ln -s /fs/cgd/data0/hecht/mapping/scrip1.4/scrip scrip ln -s /fs/cgd/data0/hecht/mapping/scrip1.4/scrip_test scrip_test scrip > map_gx3v4_and_T31_aave_da_020513.out ------------------------ -- Testing of Weights -- ------------------------ -- Run ferret and check stats of both maps (see that min value is not substantially below zero): set data map_T31_to_gx3v4_aave_da_020513.nc stats s S X: 0.5 to 23267.5 Y: N/A Z: N/A T: N/A DATA SET: ./map_T31_to_gx3v4_aave_da_020513.nc Total # of data points: 23267 (23267*1*1*1) # flagged as bad data: 0 Minimum value: -3.851E-06 Maximum value: 1 Mean value: 0.34495 (unweighted average) Standard deviation: 0.29132 set data map_gx3v4_to_T31_aave_da_020513.nc stats s S X: 0.5 to 23267.5 Y: N/A Z: N/A T: N/A DATA SET: ./map_gx3v4_to_T31_aave_da_020513.nc Total # of data points: 23267 (23267*1*1*1) # flagged as bad data: 0 Minimum value: -6.088E-06 Maximum value: 0.67392 Mean value: 0.13071 (unweighted average) Standard deviation: 0.11794 -- Run scrip_test for T31_to_gx3v4: In SCRIP directory, write scrip_test_in: cat >! scrip_test_in &remap_inputs field_choice = 2 interp_file = 'map_T31_to_gx3v4_aave_da_020513.nc' output_file = 'test_T31_to_gx3v4_aave_da_020513.nc' / scrip_test > ! test_T31_to_gx3v4_aave_da_020513.out Inspect output netcdf file out[...].nc file with ferret. yes? set data test_T31_to_gx3v4_aave_da_020513.nc yes? shade src_array yes? shade dst_array1 yes? shade dst_error1 Append some of the output of scrip_test to the map file, documenting error field: 1) copy the output from scrip_test to tmp file called foo 2) edit foo, saving FIELD_CHOICE and all lines from First order mapping from grid1 to grid2: on down. 3) replace each end-of-line with \n 4) append this business as a global ncdf attribute: ncatted -O -h -a scrip_test_output,global,a,c,"`cat foo`" map_T31_to_gx3v4_aave_da_020513.nc -- Run scrip_test for gx3v4_to_T31: In SCRIP directory, write scrip_test_in: cat >! scrip_test_in &remap_inputs field_choice = 2 interp_file = 'map_gx3v4_to_T31_aave_da_020513.nc' output_file = 'test_gx3v4_to_T31_aave_da_020513.nc' / scrip_test > ! test_gx3v4_to_T31_aave_da_020513.out Inspect output netcdf file out[...].nc file with ferret. set data test_gx3v4_to_T31_aave_da_020513.nc shade src_array shade dst_array1 shade dst_error1 Append some of the output of scrip_test to the map file, documenting error field: 1) copy the output from scrip_test to tmp file called foo 2) edit foo, saving FIELD_CHOICE and all lines from First order mapping from grid1 to grid2: on down. 3) replace each end-of-line with \n 4) append this business as a global ncdf attribute: ncatted -O -h -a scrip_test_output,global,a,c,"`cat foo`" \ map_gx3v4_to_T31_aave_da_020513.nc ------------------------------ -- Consistency of Grid Data -- ------------------------------ If this is not the first mapping file produced for this ocean (ice) grid, then check that the grid info included in the map.nc file agrees with that from existing files. ------------- -- Caution -- ------------- Brian has some test code built into the coupler that 1) checks that array elements are in [0,1] 2) checks that array rows add up to one (or zero for masked out regions) 3) checks what percent of array rows add up to one (eg. a->o should be about 70%) 4) checks that SCRIP domain info is compatible with info sent to cpl at run time. For now, this information must be inspected the first time a map is used by the cpl. In the near future we will have stand-alone code to do this. --------------- -- Finish up -- --------------- If mappings are ok then, again, add documentation: ncatted -O -h -a Created_by,global,a,c,"`whoami`, `date`" map_T31_to_gx3v4_aave_da_020513.nc ncatted -O -h -a 1D_grid_indexing,global,a,c,"if n is 1D index, i runs fast, j runs slow: n=(j-1)*fast_grid_dim+i" map_T31_to_gx3v4_aave_da_020513.nc ncatted -O -h -a Created_by,global,a,c,"`whoami`, `date`" map_gx3v4_to_T31_aave_da_020513.nc ncatted -O -h -a 1D_grid_indexing,global,a,c,"if n is 1D index, i runs fast, j runs slow: n=(j-1)*fast_grid_dim+i" map_gx3v4_to_T31_aave_da_020513.nc and to be installed in /fs/cgd/csm/mapping/maps: (do later) mv map_T31_to_gx3v4_aave_da_020513.nc /fs/cgd/csm/mapping/maps chgrp cgdcsm /fs/cgd/csm/mapping/maps/map_T31_to_gx3v4_aave_da_020513.nc chmod 444 /fs/cgd/csm/mapping/maps/map_T31_to_gx3v4_aave_da_020513.nc mv map_T31_to_gx3v4_aave_da_020513.readme /fs/cgd/csm/mapping/maps chgrp cgdcsm /fs/cgd/csm/mapping/maps/map_T31_to_gx3v4_aave_da_020513.readme chmod 444 /fs/cgd/csm/mapping/maps/map_T31_to_gx3v4_aave_da_020513.readme mv map_gx3v4_to_T31_aave_da_020513.nc /fs/cgd/csm/mapping/maps chgrp cgdcsm /fs/cgd/csm/mapping/maps/map_gx3v4_to_T31_aave_da_020513.nc chmod 444 /fs/cgd/csm/mapping/maps/map_gx3v4_to_T31_aave_da_020513.nc ln -s /fs/cgd/csm/mapping/maps/map_T31_to_gx3v4_aave_da_020513.readme \ /fs/cgd/csm/mapping/maps/map_gx3v4_to_T31_aave_da_020513.readme