00001 module map_glcglc_mct
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 use shr_sys_mod
00014 use mct_mod
00015 use seq_comm_mct
00016 use seq_cdata_mod
00017 use seq_rearr_mod
00018
00019 implicit none
00020 save
00021 private
00022
00023
00024
00025
00026
00027 public :: map_glc2glc_init_mct
00028 public :: map_glcx2glcg_mct
00029 public :: map_glcg2glcx_mct
00030
00031
00032
00033 interface map_glc2glc_init_mct; module procedure &
00034 map_ccc2ccc_init_mct
00035 end interface
00036 interface map_glcx2glcg_mct; module procedure &
00037 map_xxx2ccc_mct
00038 end interface
00039 interface map_glcg2glcx_mct; module procedure &
00040 map_ccc2xxx_mct
00041 end interface
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 type(mct_rearr), private :: Re_xxx2ccc
00052 type(mct_rearr), private :: Re_ccc2xxx
00053
00054 #ifdef CPP_VECTOR
00055 logical :: usevector = .true.
00056 #else
00057 logical :: usevector = .false.
00058 #endif
00059
00060 #ifdef SYSUNICOS
00061 logical :: usealltoall = .true.
00062 #else
00063 logical :: usealltoall = .false.
00064 #endif
00065
00066 logical :: copyoption = .true.
00067 logical :: gsmapSame = .false.
00068 character(*),parameter :: subName = '(map_glcglc_mct)'
00069
00070
00071 contains
00072
00073
00074 subroutine map_ccc2ccc_init_mct( cdata_cc, x2c_cc, c2x_cc, ID_cc, &
00075 cdata_cx, x2c_cx, c2x_cx, ID_cx, ID_join)
00076
00077 implicit none
00078
00079
00080
00081
00082 type(seq_cdata),intent(in) :: cdata_cc
00083 type(mct_aVect),intent(inout) :: x2c_cc
00084 type(mct_aVect),intent(inout) :: c2x_cc
00085 integer ,intent(in) :: ID_cc
00086 type(seq_cdata),intent(inout) :: cdata_cx
00087 type(mct_aVect),intent(inout) :: x2c_cx
00088 type(mct_aVect),intent(inout) :: c2x_cx
00089 integer ,intent(in) :: ID_cx
00090 integer ,intent(in) :: ID_join
00091
00092
00093
00094 character(len=*),parameter :: subname = "(map_glc2glc_init_mct) "
00095 type(mct_gsmap),pointer :: gsmap_cc
00096 type(mct_gsmap),pointer :: gsmap_cx
00097
00098
00099
00100 call seq_rearr_init( cdata_cc, x2c_cc, c2x_cc, ID_cc, &
00101 cdata_cx, x2c_cx, c2x_cx, ID_cx, ID_join, &
00102 Re_ccc2xxx, Re_xxx2ccc)
00103
00104 call seq_cdata_setptrs(cdata_cc,gsmap=gsmap_cc)
00105 call seq_cdata_setptrs(cdata_cx,gsmap=gsmap_cx)
00106
00107 if (seq_rearr_gsmapIdentical(gsmap_cc,gsmap_cx)) then
00108 gsmapsame = .true.
00109 if (seq_comm_iamroot(ID_join)) then
00110 write(logunit,'(2A,L2)') subname,' gsmaps ARE IDENTICAL, copyoption = ',copyoption
00111 endif
00112 else
00113 if (seq_comm_iamroot(ID_join)) write(logunit,'(2A)') subname,' gsmaps are not identical'
00114 gsmapsame = .false.
00115 endif
00116
00117 end subroutine map_ccc2ccc_init_mct
00118
00119
00120
00121 subroutine map_ccc2xxx_mct( cdata_cc, av_cc, cdata_cx, av_cx, fldlist )
00122
00123
00124
00125
00126
00127 type(seq_cdata),intent(in) :: cdata_cc
00128 type(mct_aVect),intent(in) :: av_cc
00129 type(seq_cdata),intent(in) :: cdata_cx
00130 type(mct_aVect),intent(out):: av_cx
00131 character(len=*),intent(in), optional :: fldlist
00132
00133 character(len=*),parameter :: subname = "(map_glcg2glcx_mct) "
00134 type(mct_aVect) :: av_test
00135 integer :: k,n
00136
00137 if (copyoption .and. gsmapsame) then
00138 if (present(fldlist)) then
00139 call mct_aVect_copy(aVin=av_cc,aVout=av_cx,rList=fldlist,vector=usevector)
00140 else
00141 call mct_aVect_copy(aVin=av_cc,aVout=av_cx,vector=usevector)
00142 endif
00143 else
00144 if (present(fldlist)) then
00145 call mct_rearr_rearrange_fldlist(av_cc, av_cx, Re_ccc2xxx, VECTOR=usevector, &
00146 ALLTOALL=usealltoall, fldlist=fldlist)
00147 else
00148 call mct_rearr_rearrange(av_cc, av_cx, Re_ccc2xxx, VECTOR=usevector, ALLTOALL=usealltoall)
00149 endif
00150 end if
00151
00152
00153 #if (1 == 0)
00154 call mct_avect_init(av_test,av_cc,mct_avect_lsize(av_cc))
00155 call mct_rearr_rearrange(av_cx, av_test, Re_xxx2ccc, VECTOR=usevector, ALLTOALL=usealltoall)
00156 do k = 1,mct_avect_nRattr(av_cc)
00157 do n = 1,mct_avect_lsize(av_cc)
00158 if (av_cc%rAttr(k,n) /= av_test%rAttr(k,n)) then
00159 write(6,*) 'tcz r1 ',mct_avect_nRattr(av_cc),mct_avect_nRattr(av_test),mct_avect_lsize(av_cc),mct_avect_lsize(av_test),mct_avect_lsize(av_cx)
00160 write(6,*) 'tcz diff ',k,n,av_cc%rAttr(k,n),av_test%rAttr(k,n)
00161 call shr_sys_flush(6)
00162 call shr_sys_abort()
00163 endif
00164 enddo
00165 enddo
00166 call mct_avect_clean(av_test)
00167 #endif
00168
00169 end subroutine map_ccc2xxx_mct
00170
00171
00172
00173 subroutine map_xxx2ccc_mct( cdata_cx, av_cx, cdata_cc, av_cc, fldlist)
00174
00175
00176
00177
00178
00179 type(seq_cdata),intent(in) :: cdata_cx
00180 type(mct_aVect),intent(in) :: av_cx
00181 type(seq_cdata),intent(in) :: cdata_cc
00182 type(mct_aVect),intent(out):: av_cc
00183 character(len=*),intent(in), optional :: fldlist
00184
00185 character(len=*),parameter :: subname = "(map_glcx2glcg_mct) "
00186
00187 if (copyoption .and. gsmapsame) then
00188 if (present(fldlist)) then
00189 call mct_aVect_copy(aVin=av_cx,aVout=av_cc,rList=fldlist,vector=usevector)
00190 else
00191 call mct_aVect_copy(aVin=av_cx,aVout=av_cc,vector=usevector)
00192 endif
00193 else
00194 if (present(fldlist)) then
00195 call mct_rearr_rearrange_fldlist(av_cx, av_cc, Re_xxx2ccc, VECTOR=usevector, &
00196 ALLTOALL=usealltoall, fldlist=fldlist)
00197 else
00198 call mct_rearr_rearrange(av_cx, av_cc, Re_xxx2ccc, VECTOR=usevector, ALLTOALL=usealltoall)
00199 endif
00200 end if
00201
00202 end subroutine map_xxx2ccc_mct
00203
00204
00205
00206
00207 end module map_glcglc_mct