Oasis3-MCT
 All Classes Files Functions Variables Macros Pages
Data Types | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
mod_oasis_map Module Reference

OASIS map (interpolation) data and methods. More...

Data Types

type  prism_mapper_type
 Mapper data for interpolating data between grids. More...
 

Public Member Functions

subroutine, public oasis_map_genmap (mapid, namid)
 Routine to generate mapping weights data via a direct SCRIP call. More...
 
subroutine, public oasis_map_smatreaddnc_orig (sMat, SgsMap, DgsMap, newdom, fileName, mytask, mpicom, nwgts, areasrc, areadst, ni_i, nj_i, ni_o, nj_o)
 Read in mapping matrix data from a SCRIP netCDF weights file. More...
 
subroutine, public oasis_map_smatreaddnc_ceg (sMat, SgsMap, DgsMap, newdom, fileName, mytask, mpicom, nwgts, areasrc, areadst, ni_i, nj_i, ni_o, nj_o)
 Read in mapping matrix data from a SCRIP netCDF file using smart scatter (ceg) More...
 

Public Attributes

integer(kind=ip_i4_p), public prism_mmapper
 max mappers More...
 
integer(kind=ip_i4_p), public prism_nmapper = 0
 mapper counter More...
 
type(prism_mapper_type),
dimension(:), pointer, public 
prism_mapper
 list of defined mappers More...
 

Private Member Functions

logical function check_myindex (index, starti, counti)
 Function that checks whether an index is part of a start and count list. More...
 
subroutine augment_arrays (cnt, reclen, bsize, nwgts)
 
integer function get_cegindex (index, starti, counti, peloci)
 

Private Attributes

integer, parameter, private r8 = ip_double_p
 
integer, parameter, private in = ip_i4_p
 
real(r8), dimension(:,:),
allocatable, private 
snew
 
real(r8), dimension(:,:),
allocatable, private 
sold
 
integer, dimension(:),
allocatable, private 
rnew
 
integer, dimension(:),
allocatable, private 
rold
 
integer, dimension(:),
allocatable, private 
cnew
 
integer, dimension(:),
allocatable, private 
cold
 

Detailed Description

OASIS map (interpolation) data and methods.

Definition at line 5 of file mod_oasis_map.F90.

Member Function/Subroutine Documentation

subroutine mod_oasis_map::augment_arrays ( integer, intent(inout)  cnt,
integer, intent(in reclen,
integer, intent(inout)  bsize,
integer, intent(in nwgts 
)
private

Definition at line 1528 of file mod_oasis_map.F90.

logical function mod_oasis_map::check_myindex ( integer(in index,
integer(in), dimension(:)  starti,
integer(in), dimension(:)  counti 
)
private

Function that checks whether an index is part of a start and count list.

Does a binary search on a sorted start and count list to determine whether index is a value in the list. The list values consist of the values start(i):start(i)+count(i)-1 for all i.

Parameters
indexindex to search
startistart list
counticount list

Definition at line 845 of file mod_oasis_map.F90.

integer function mod_oasis_map::get_cegindex ( integer(in index,
integer(in), dimension(:)  starti,
integer(in), dimension(:)  counti,
integer(in), dimension(:)  peloci 
)
private
Parameters
indexindex to search
startistart list
counticount list
pelocipe list

Definition at line 1585 of file mod_oasis_map.F90.

subroutine, public mod_oasis_map::oasis_map_genmap ( integer(ip_i4_p), intent(in mapid,
integer(ip_i4_p), intent(in namid 
)

Routine to generate mapping weights data via a direct SCRIP call.

This routine reads in grid data from files and passes that data to SCRIP. Mapping weights are generated and written to a file. This entire operation is done on a single task.

Parameters
[in]mapidmap id
[in]namidnamcouple id

Definition at line 78 of file mod_oasis_map.F90.

subroutine, public mod_oasis_map::oasis_map_smatreaddnc_ceg ( type(mct_smat), dimension(:), intent(out), pointer  sMat,
type(mct_gsmap), intent(in), target  SgsMap,
type(mct_gsmap), intent(in), target  DgsMap,
character(*), intent(in newdom,
character(*), intent(in fileName,
integer(in), intent(in mytask,
integer(in), intent(in mpicom,
integer(in), intent(out)  nwgts,
type(mct_avect), intent(out), optional  areasrc,
type(mct_avect), intent(out), optional  areadst,
integer(in), intent(out), optional  ni_i,
integer(in), intent(out), optional  nj_i,
integer(in), intent(out), optional  ni_o,
integer(in), intent(out), optional  nj_o 
)

Read in mapping matrix data from a SCRIP netCDF file using smart scatter (ceg)

Read in mapping matrix data from a SCRIP netCDF data file using a low memory method and then scatter to all pes using a smart method where only select data is sent to tasks. Based on the sMatReaddnc method from CESM1.0.3 This routine leverages gsmaps to determine scatter pattern

The scatter is implemented via the root task reading the data and then determining which task gets which weights from the gsmap. The root the sends specific data to each task.

The algorithm to determine which task a weigth belongs to involves checking the task ownership for a given global index.

The local buffer sizes are estimated up front based on ngridcell/npes plus 20% (see 1.2 below). If the local buffer size fills up, then the buffer is reallocated 50% larger (see 1.5 below) and the fill continues. The idea is to trade off memory reallocation and copy with memory usage. 1.2 and 1.5 are arbitary, other values may result in better performance.

Once all the matrix weights have been read, the sMat is initialized, the values from the buffers are copied in, and everything is deallocated.

Parameters
[out]smatmapping data
[in]sgsmapsrc gsmap
[in]dgsmapdst gsmap
[in]newdomtype of sMat (src or dst) src = rearrange and map (bfb), dst = map and rearrange (partial sums)
[in]filenamenetCDF file to read
[in]mytaskprocessor id
[in]mpicommpi communicator
[out]nwgtsnumber of weights
[out]areasrcarea of src grid from mapping file
[out]areadstarea of dst grid from mapping file
[out]ni_inumber of lons on input grid
[out]nj_inumber of lats on input grid
[out]ni_onumber of lons on output grid
[out]nj_onumber of lats on output grid
  • Open and read the file SCRIP weights size on the root task
  • Read and load area_a on root task
  • Read and load area_b on root task
  • Broadcast ni and nj if requested
  • Broadcast array sizes and allocate arrays for local storage
  • Compute the number of chunks to read, read size is rbuf_size
  • Allocate arrays for local weights plus row and column indices
  • On the root task
    • Initialize lsstart and lscount, the sorted list of local indices
    • Allocate arrays for reading data on the root
    • Loop over the chunks of weights data
    • Read chunk of data
    • Determine which process owns each weight and count them
    • Determine offsets in the array
    • Determine which process owns each weight and fill arrays
    • Send select data from root to other processes
    • Deallocate memory on root process
  • On non-root processes
    • Receive data from root
    • Reallocate local weights arrays if they need to be bigger
  • Clean up arrays
  • Initialize the mct sMat data type
  • More clean up

Definition at line 941 of file mod_oasis_map.F90.

subroutine, public mod_oasis_map::oasis_map_smatreaddnc_orig ( type(mct_smat), dimension(:), intent(out), pointer  sMat,
type(mct_gsmap), intent(in), target  SgsMap,
type(mct_gsmap), intent(in), target  DgsMap,
character(*), intent(in newdom,
character(*), intent(in fileName,
integer(in), intent(in mytask,
integer(in), intent(in mpicom,
integer(in), intent(out)  nwgts,
type(mct_avect), intent(out), optional  areasrc,
type(mct_avect), intent(out), optional  areadst,
integer(in), intent(out), optional  ni_i,
integer(in), intent(out), optional  nj_i,
integer(in), intent(out), optional  ni_o,
integer(in), intent(out), optional  nj_o 
)

Read in mapping matrix data from a SCRIP netCDF weights file.

Read in mapping matrix data from a SCRIP netCDF data file using a low memory method and then scatter to all pes. Based on the sMatReaddnc method from CESM1.0.3. This routine leverages gsmaps to determine scatter pattern.

The scatter is implemented as a broadcast of all weights then a local computation on each pe to determine with weights to keep based on gsmap information.

The algorithm to determine whether a weight belongs on a pe involves creating a couple local arrays (lsstart and lscount) which are the local values of start and length from the gsmap. These are sorted via a bubble sort and then searched via a binary search to check whether a global index is on the local pe.

The local buffer sizes are estimated up front based on ngridcell/npes plus 20% (search for 1.2 below). If the local buffer size fills up, then the buffer is reallocated 50% larger (search for 1.5 below) and the fill continues. The idea is to trade off memory reallocation and copy with memory usage. 1.2 and 1.5 are arbitary, other values may result in better performance.

Once all the matrix weights have been read, the sMat is initialized, the values from the buffers are copied in, and everything is deallocated.

Parameters
[out]smatmapping data
[in]sgsmapsrc gsmap
[in]dgsmapdst gsmap
[in]newdomtype of sMat (src or dst) src = rearrange and map (bfb), dst = map and rearrange (partial sums)
[in]filenamenetCDF file to read
[in]mytaskprocessor id
[in]mpicommpi communicator
[out]nwgtsnumber of weights
[out]areasrcarea of src grid from mapping file
[out]areadstarea of dst grid from mapping file
[out]ni_inumber of lons on input grid
[out]nj_inumber of lats on input grid
[out]ni_onumber of lons on output grid
[out]nj_onumber of lats on output grid
  • Open and read the file SCRIP weights size on the root task
  • Read and load area_a on root task
  • Read and load area_b on root task
  • Broadcast ni and nj if requested
  • Broadcast array sizes and allocate arrays for local storage
  • Initialize lsstart and lscount, the sorted list of local indices
  • Compute the number of chunks to read, read size is rbuf_size
  • Allocate arrays for local weights plus row and column indices
  • Loop over the chunks of weights data
    • Read chunk of data on root pe
    • Broadcast S, row, col to all tasks
    • Each task keeps only the data required
    • Reallocate local weights arrays if they need to be bigger
  • Clean up arrays
  • Initialize the mct sMat data type
  • More clean up

Definition at line 368 of file mod_oasis_map.F90.

Member Data Documentation

integer, dimension(:), allocatable, private mod_oasis_map::cnew
private

Definition at line 64 of file mod_oasis_map.F90.

integer, dimension(:), allocatable, private mod_oasis_map::cold
private

Definition at line 64 of file mod_oasis_map.F90.

integer, parameter, private mod_oasis_map::in = ip_i4_p
private

Definition at line 58 of file mod_oasis_map.F90.

type(prism_mapper_type), dimension(:), pointer, public mod_oasis_map::prism_mapper

list of defined mappers

Definition at line 53 of file mod_oasis_map.F90.

integer(kind=ip_i4_p), public mod_oasis_map::prism_mmapper

max mappers

Definition at line 51 of file mod_oasis_map.F90.

integer(kind=ip_i4_p), public mod_oasis_map::prism_nmapper = 0

mapper counter

Definition at line 52 of file mod_oasis_map.F90.

integer, parameter, private mod_oasis_map::r8 = ip_double_p
private

Definition at line 57 of file mod_oasis_map.F90.

integer, dimension(:), allocatable, private mod_oasis_map::rnew
private

Definition at line 63 of file mod_oasis_map.F90.

integer, dimension(:), allocatable, private mod_oasis_map::rold
private

Definition at line 63 of file mod_oasis_map.F90.

real(r8), dimension(:,:), allocatable, private mod_oasis_map::snew
private

Definition at line 62 of file mod_oasis_map.F90.

real(r8), dimension(:,:), allocatable, private mod_oasis_map::sold
private

Definition at line 62 of file mod_oasis_map.F90.


The documentation for this module was generated from the following file: