00001 module map_rofocn_mct
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 use shr_sys_mod
00015 use shr_mct_mod, only: shr_mct_sMatPInitnc
00016 use mct_mod
00017 use seq_cdata_mod
00018 use seq_infodata_mod
00019 implicit none
00020
00021 private
00022
00023
00024
00025
00026
00027 public :: map_rof2ocn_init_mct
00028 public :: map_rof2ocn_mct
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 type(mct_rearr), private :: Re_rof2ocn
00039 type(mct_sMatp), private :: sMatp_Fr2o
00040
00041 #ifdef CPP_VECTOR
00042 logical :: usevector = .true.
00043 #else
00044 logical :: usevector = .false.
00045 #endif
00046
00047 #ifdef SYSUNICOS
00048 logical :: usealltoall = .true.
00049 #else
00050 logical :: usealltoall = .false.
00051 #endif
00052
00053 logical, private :: samegrid_mapr2o
00054
00055 character(*),parameter :: subName = '(map_rofocn_mct) '
00056
00057
00058 contains
00059
00060
00061 subroutine map_rof2ocn_init_mct( cdata_r, cdata_o)
00062
00063
00064
00065
00066
00067 type(seq_cdata),intent(in) :: cdata_r
00068 type(seq_cdata),intent(in) :: cdata_o
00069
00070
00071
00072 integer :: km,ka
00073 type(seq_infodata_type), pointer :: infodata
00074 type(mct_gsMap), pointer :: gsMap_r
00075 type(mct_gsMap), pointer :: gsMap_o
00076 type(mct_ggrid), pointer :: dom_r
00077 type(mct_ggrid), pointer :: dom_o
00078 integer :: mpicom
00079 integer :: lsize
00080 type(mct_aVect) :: areasrc
00081 type(mct_aVect) :: areadst
00082 type(mct_rearr) :: Re_ocn2rof
00083
00084 character(*),parameter :: subName = '(map_rof2ocn_mct) '
00085
00086
00087
00088
00089 call seq_cdata_setptrs(cdata_r, gsMap=gsMap_r, dom=dom_r)
00090 call seq_cdata_setptrs(cdata_o, gsMap=gsMap_o, dom=dom_o)
00091 call seq_cdata_setptrs(cdata_o, mpicom=mpicom, infodata=infodata)
00092
00093 call seq_infodata_GetData(infodata, samegrid_ro=samegrid_mapr2o)
00094
00095 if (samegrid_mapr2o) then
00096
00097 call mct_rearr_init(gsMap_r, gsMap_o, mpicom, Re_rof2ocn)
00098 call mct_rearr_init(gsMap_o, gsMap_r, mpicom, Re_ocn2rof)
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112 call mct_rearr_rearrange_fldlist(dom_o%data, dom_r%data, Re_ocn2rof, VECTOR=usevector, &
00113 ALLTOALL=usealltoall, fldlist='aream')
00114
00115 call mct_rearr_clean(Re_ocn2rof)
00116
00117
00118
00119
00120
00121
00122
00123
00124 else
00125
00126
00127
00128 lsize = mct_gsMap_lsize(gsMap_r, mpicom)
00129 call mct_aVect_init( areasrc, rList="aream", lsize=lsize )
00130
00131 call shr_mct_sMatPInitnc(sMatp_Fr2o, gsMap_r, gsMap_o, "seq_maps.rc", &
00132 "rof2ocnFmapname:","rof2ocnFmaptype:",mpicom, &
00133 areasrc=areasrc)
00134
00135
00136
00137 km = mct_aVect_indexRA(dom_r%data,"aream", perrWith=subName)
00138 ka = mct_aVect_indexRA(areasrc ,"aream", perrWith=subName)
00139 dom_r%data%rAttr(km,:) = areasrc%rAttr(ka,:)
00140
00141 call mct_aVect_clean(areasrc)
00142
00143 endif
00144
00145 end subroutine map_rof2ocn_init_mct
00146
00147
00148
00149 subroutine map_rof2ocn_mct( cdata_r, r2x_r, cdata_o, r2x_o)
00150
00151 type(seq_cdata),intent(in) :: cdata_r
00152 type(mct_aVect),intent(in) :: r2x_r
00153 type(seq_cdata),intent(in) :: cdata_o
00154 type(mct_aVect),intent(out):: r2x_o
00155
00156 if (samegrid_mapr2o) then
00157
00158 call mct_rearr_rearrange(r2x_r, r2x_o, Re_rof2ocn, VECTOR=usevector, &
00159 ALLTOALL=usealltoall)
00160
00161 else
00162
00163
00164 call mct_sMat_avMult(r2x_r, sMatp_Fr2o, r2x_o, VECTOR=usevector)
00165
00166 endif
00167
00168 end subroutine map_rof2ocn_mct
00169
00170
00171
00172 end module map_rofocn_mct