Oasis3-MCT
Data Types | Functions/Subroutines | Variables
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...
 

Functions/Subroutines

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...
 
subroutine augment_arrays (cnt, reclen, bsize, nwgts)
 Function that increases temporary work array size of Snew, Rnew, Cnew. More...
 
logical function check_myindex (index, starti, counti)
 Function that checks whether an index is part of a start and count list. More...
 
integer function get_cegindex (index, starti, counti, peloci)
 Function that carrys out a binary search for index in list. More...
 

Variables

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...
 
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
 
logical, parameter local_timers_on = .false.
 

Detailed Description

OASIS map (interpolation) data and methods.

Function/Subroutine Documentation

◆ augment_arrays()

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

Function that increases temporary work array size of Snew, Rnew, Cnew.

Parameters
[in,out]cntelements in current array
[in]reclenelements of new data
[in,out]bsizemax size of current array
[in]nwgtsnumber of weights in S

Definition at line 1603 of file mod_oasis_map.F90.

◆ check_myindex()

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 1663 of file mod_oasis_map.F90.

◆ get_cegindex()

integer function mod_oasis_map::get_cegindex ( integer(in index,
integer(in), dimension(:)  starti,
integer(in), dimension(:)  counti,
integer(in), dimension(:)  peloci 
)
private

Function that carrys out a binary search for index in list.

Parameters
indexindex to search
startistart list
counticount list
pelocipe list

Definition at line 1738 of file mod_oasis_map.F90.

◆ oasis_map_genmap()

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 83 of file mod_oasis_map.F90.

◆ oasis_map_smatreaddnc_ceg()

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, lscount, and lspeloc, the sorted list of local indices
    • Sort via bubble sort or merge sort depending on size of array
    • 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 931 of file mod_oasis_map.F90.

◆ oasis_map_smatreaddnc_orig()

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 377 of file mod_oasis_map.F90.

Variable Documentation

◆ cnew

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

Definition at line 66 of file mod_oasis_map.F90.

◆ cold

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

Definition at line 66 of file mod_oasis_map.F90.

◆ in

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

Definition at line 60 of file mod_oasis_map.F90.

◆ local_timers_on

logical, parameter mod_oasis_map::local_timers_on = .false.
private

Definition at line 68 of file mod_oasis_map.F90.

◆ prism_mapper

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

list of defined mappers

Definition at line 55 of file mod_oasis_map.F90.

◆ prism_mmapper

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

max mappers

Definition at line 53 of file mod_oasis_map.F90.

◆ prism_nmapper

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

mapper counter

Definition at line 54 of file mod_oasis_map.F90.

◆ r8

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

Definition at line 59 of file mod_oasis_map.F90.

◆ rnew

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

Definition at line 65 of file mod_oasis_map.F90.

◆ rold

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

Definition at line 65 of file mod_oasis_map.F90.

◆ snew

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

Definition at line 64 of file mod_oasis_map.F90.

◆ sold

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

Definition at line 64 of file mod_oasis_map.F90.