00001 module map_iceocn_mct
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 use shr_sys_mod
00014 use mct_mod
00015 use seq_cdata_mod
00016 use seq_comm_mct
00017
00018 implicit none
00019 save
00020 private
00021
00022
00023
00024
00025
00026 public :: map_ice2ocn_init_mct
00027 public :: map_ocn2ice_init_mct
00028 public :: map_ice2ocn_mct
00029 public :: map_ocn2ice_mct
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 type(mct_rearr), private :: Re_ice2ocn
00040 type(mct_rearr), private :: Re_ocn2ice
00041
00042 #ifdef CPP_VECTOR
00043 logical :: usevector = .true.
00044 #else
00045 logical :: usevector = .false.
00046 #endif
00047
00048 #ifdef SYSUNICOS
00049 logical :: usealltoall = .true.
00050 #else
00051 logical :: usealltoall = .false.
00052 #endif
00053
00054 character(*),parameter :: subName = '(map_iceocn_mct)'
00055
00056
00057 contains
00058
00059
00060 subroutine map_ocn2ice_init_mct( cdata_o, cdata_i)
00061
00062
00063
00064
00065
00066 type(seq_cdata),intent(in) :: cdata_o
00067 type(seq_cdata),intent(in) :: cdata_i
00068
00069
00070
00071 integer :: ka, km
00072 integer :: ocnsize, icesize
00073 type(mct_gsMap), pointer :: gsMap_i
00074 type(mct_gsMap), pointer :: gsMap_o
00075 type(mct_gGrid), pointer :: dom_i
00076 type(mct_gGrid), pointer :: dom_o
00077 integer :: mpicom
00078 integer :: lsize
00079 type(mct_aVect) :: areasrc
00080 type(mct_aVect) :: areadst
00081
00082
00083 call seq_cdata_setptrs(cdata_o, gsMap=gsMap_o, dom=dom_o)
00084 call seq_cdata_setptrs(cdata_i, gsMap=gsMap_i, dom=dom_i)
00085 call seq_cdata_setptrs(cdata_o, mpicom=mpicom)
00086
00087
00088
00089 ocnsize = mct_gsMap_gsize(gsMap_o)
00090 icesize = mct_gsMap_gsize(gsMap_i)
00091 if (ocnsize /= icesize) then
00092 write(logunit,*) "(map_ocn2ice_init_mct) ocean and ice are different."
00093 write(logunit,*) "(map_ocn2ice_init_mct) Must be t.Exiting."
00094 call shr_sys_abort(subName // "different ocn")
00095 endif
00096
00097
00098
00099 call mct_rearr_init(gsMap_o, gsMap_i, mpicom, Re_ocn2ice)
00100
00101
00102
00103
00104 lsize = mct_gsMap_lsize(gsMap_o, mpicom)
00105 call mct_aVect_init( areasrc, rList="aream", lsize=lsize )
00106
00107 lsize = mct_gsMap_lsize(gsMap_i, mpicom)
00108 call mct_aVect_init( areadst, rList="aream", lsize=lsize )
00109
00110 km = mct_aVect_indexRA(dom_o%data,"aream")
00111 ka = mct_aVect_indexRA(areasrc ,"aream")
00112 areasrc%rAttr(ka,:) = dom_o%data%rAttr(km,:)
00113
00114 call mct_rearr_rearrange(areasrc, areadst, Re_ocn2ice, VECTOR=usevector, ALLTOALL=usealltoall)
00115
00116 ka = mct_aVect_indexRA(areadst ,"aream")
00117 km = mct_aVect_indexRA(dom_i%data,"aream")
00118 dom_i%data%rAttr(km,:) = areadst%rAttr(ka,:)
00119
00120 call mct_aVect_clean(areasrc)
00121 call mct_aVect_clean(areadst)
00122
00123 end subroutine map_ocn2ice_init_mct
00124
00125
00126
00127 subroutine map_ice2ocn_init_mct( cdata_i, cdata_o)
00128
00129
00130
00131
00132
00133 type(seq_cdata),intent(in) :: cdata_i
00134 type(seq_cdata),intent(in) :: cdata_o
00135
00136
00137
00138 integer :: ocnsize, icesize
00139 type(mct_gsMap), pointer :: gsMap_i
00140 type(mct_gsMap), pointer :: gsMap_o
00141 integer :: mpicom
00142
00143
00144 call seq_cdata_setptrs(cdata_i, gsMap=gsMap_i)
00145 call seq_cdata_setptrs(cdata_o, gsMap=gsMap_o)
00146 call seq_cdata_setptrs(cdata_o, mpicom=mpicom)
00147
00148
00149
00150 ocnsize = mct_gsMap_gsize(gsMap_o)
00151 icesize = mct_gsMap_gsize(gsMap_i)
00152 if (ocnsize /= icesize) then
00153 write(logunit,*) "(map_ice2ocn_init_mct) ocean and ice grids are different."
00154 write(logunit,*) "(map_ice2ocn_init_mct) Must be the same....Exiting."
00155 call shr_sys_abort(subName // "different ocn,ice grids")
00156 endif
00157
00158
00159
00160 call mct_rearr_init(gsMap_i, gsMap_o, mpicom, Re_ice2ocn)
00161
00162 end subroutine map_ice2ocn_init_mct
00163
00164
00165
00166 subroutine map_ocn2ice_mct( cdata_o, av_o, cdata_i, av_i, fluxlist, statelist )
00167
00168
00169
00170
00171
00172 type(seq_cdata),intent(in) :: cdata_o
00173 type(mct_aVect),intent(in) :: av_o
00174 type(seq_cdata),intent(in) :: cdata_i
00175 type(mct_aVect),intent(out):: av_i
00176 character(len=*),intent(in), optional :: fluxlist
00177 character(len=*),intent(in), optional :: statelist
00178
00179
00180 if (present(fluxlist) .or. present(statelist)) then
00181 if (present(fluxlist)) then
00182 call mct_rearr_rearrange_fldlist(av_o, av_i, Re_ocn2ice, VECTOR=usevector, &
00183 ALLTOALL=usealltoall, fldlist=fluxlist)
00184 endif
00185 if (present(statelist)) then
00186 call mct_rearr_rearrange_fldlist(av_o, av_i, Re_ocn2ice, VECTOR=usevector, &
00187 ALLTOALL=usealltoall, fldlist=statelist)
00188 endif
00189 else
00190 call mct_rearr_rearrange(av_o, av_i, Re_ocn2ice, VECTOR=usevector, ALLTOALL=usealltoall)
00191 end if
00192
00193 end subroutine map_ocn2ice_mct
00194
00195
00196
00197 subroutine map_ice2ocn_mct( cdata_i, av_i, cdata_o, av_o, fluxlist, statelist)
00198
00199
00200
00201
00202
00203 type(seq_cdata),intent(in) :: cdata_i
00204 type(mct_aVect),intent(in) :: av_i
00205 type(seq_cdata),intent(in) :: cdata_o
00206 type(mct_aVect),intent(out):: av_o
00207 character(len=*),intent(in), optional :: fluxlist
00208 character(len=*),intent(in), optional :: statelist
00209
00210
00211 if (present(fluxlist) .or. present(statelist)) then
00212 if (present(fluxlist)) then
00213 call mct_rearr_rearrange_fldlist(av_i, av_o, Re_ice2ocn, VECTOR=usevector, &
00214 ALLTOALL=usealltoall, fldlist=fluxlist)
00215 endif
00216 if (present(statelist)) then
00217 call mct_rearr_rearrange_fldlist(av_i, av_o, Re_ice2ocn, VECTOR=usevector, &
00218 ALLTOALL=usealltoall, fldlist=statelist)
00219 endif
00220 else
00221 call mct_rearr_rearrange(av_i, av_o, Re_ice2ocn, VECTOR=usevector, ALLTOALL=usealltoall)
00222 end if
00223
00224 end subroutine map_ice2ocn_mct
00225
00226 end module map_iceocn_mct