00001 module map_rofrof_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_rof2rof_init_mct
00028 public :: map_rofx2rofr_mct
00029 public :: map_rofr2rofx_mct
00030
00031
00032
00033 interface map_rof2rof_init_mct; module procedure &
00034 map_ccc2ccc_init_mct
00035 end interface
00036 interface map_rofx2rofr_mct; module procedure &
00037 map_xxx2ccc_mct
00038 end interface
00039 interface map_rofr2rofx_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_rofrof_mct)'
00069
00070
00071 contains
00072
00073
00074 subroutine map_ccc2ccc_init_mct( cdata_cc, c2x_cc, ID_cc, &
00075 cdata_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) :: c2x_cc
00084 integer ,intent(in) :: ID_cc
00085 type(seq_cdata),intent(inout) :: cdata_cx
00086 type(mct_aVect),intent(inout) :: c2x_cx
00087 integer ,intent(in) :: ID_cx
00088 integer ,intent(in) :: ID_join
00089
00090
00091
00092 character(len=*),parameter :: subname = "(map_rof2rof_init_mct) "
00093 type(mct_gsmap),pointer :: gsmap_cc
00094 type(mct_gsmap),pointer :: gsmap_cx
00095
00096
00097
00098 call seq_rearr_init( cdata_old=cdata_cc, AV2_old=c2x_cc, ID_old=ID_cc, &
00099 cdata_new=cdata_cx, AV2_new=c2x_cx, ID_new=ID_cx, ID_join=ID_join, &
00100 RE_old2new=Re_ccc2xxx, RE_new2old=Re_xxx2ccc)
00101
00102 call seq_cdata_setptrs(cdata_cc,gsmap=gsmap_cc)
00103 call seq_cdata_setptrs(cdata_cx,gsmap=gsmap_cx)
00104
00105 if (seq_rearr_gsmapIdentical(gsmap_cc,gsmap_cx)) then
00106 gsmapsame = .true.
00107 if (seq_comm_iamroot(ID_join)) then
00108 write(logunit,'(2A,L2)') subname,' gsmaps ARE IDENTICAL, copyoption = ',copyoption
00109 endif
00110 else
00111 if (seq_comm_iamroot(ID_join)) write(logunit,'(2A)') subname,' gsmaps are not identical'
00112 gsmapsame = .false.
00113 endif
00114
00115 end subroutine map_ccc2ccc_init_mct
00116
00117
00118
00119 subroutine map_ccc2xxx_mct( cdata_cc, av_cc, cdata_cx, av_cx, fldlist )
00120
00121
00122
00123
00124
00125 type(seq_cdata),intent(in) :: cdata_cc
00126 type(mct_aVect),intent(in) :: av_cc
00127 type(seq_cdata),intent(in) :: cdata_cx
00128 type(mct_aVect),intent(out):: av_cx
00129 character(len=*),intent(in), optional :: fldlist
00130
00131 character(len=*),parameter :: subname = "(map_rofr2rofx_mct) "
00132 type(mct_aVect) :: av_test
00133 integer :: k,n
00134
00135 if (copyoption .and. gsmapsame) then
00136 if (present(fldlist)) then
00137 call mct_aVect_copy(aVin=av_cc,aVout=av_cx,rList=fldlist,vector=usevector)
00138 else
00139 call mct_aVect_copy(aVin=av_cc,aVout=av_cx,vector=usevector)
00140 endif
00141 else
00142 if (present(fldlist)) then
00143 call mct_rearr_rearrange_fldlist(av_cc, av_cx, Re_ccc2xxx, VECTOR=usevector, &
00144 ALLTOALL=usealltoall, fldlist=fldlist)
00145 else
00146 call mct_rearr_rearrange(av_cc, av_cx, Re_ccc2xxx, VECTOR=usevector, ALLTOALL=usealltoall)
00147 endif
00148 end if
00149
00150
00151 #if (1 == 0)
00152 call mct_avect_init(av_test,av_cc,mct_avect_lsize(av_cc))
00153 call mct_rearr_rearrange(av_cx, av_test, Re_xxx2ccc, VECTOR=usevector, ALLTOALL=usealltoall)
00154 do k = 1,mct_avect_nRattr(av_cc)
00155 do n = 1,mct_avect_lsize(av_cc)
00156 if (av_cc%rAttr(k,n) /= av_test%rAttr(k,n)) then
00157 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)
00158 write(6,*) 'tcz diff ',k,n,av_cc%rAttr(k,n),av_test%rAttr(k,n)
00159 call shr_sys_flush(6)
00160 call shr_sys_abort()
00161 endif
00162 enddo
00163 enddo
00164 call mct_avect_clean(av_test)
00165 #endif
00166
00167 end subroutine map_ccc2xxx_mct
00168
00169
00170
00171 subroutine map_xxx2ccc_mct( cdata_cx, av_cx, cdata_cc, av_cc, fldlist)
00172
00173
00174
00175
00176
00177 type(seq_cdata),intent(in) :: cdata_cx
00178 type(mct_aVect),intent(in) :: av_cx
00179 type(seq_cdata),intent(in) :: cdata_cc
00180 type(mct_aVect),intent(out):: av_cc
00181 character(len=*),intent(in), optional :: fldlist
00182
00183 character(len=*),parameter :: subname = "(map_rofx2rofr_mct) "
00184
00185 if (copyoption .and. gsmapsame) then
00186 if (present(fldlist)) then
00187 call mct_aVect_copy(aVin=av_cx,aVout=av_cc,rList=fldlist,vector=usevector)
00188 else
00189 call mct_aVect_copy(aVin=av_cx,aVout=av_cc,vector=usevector)
00190 endif
00191 else
00192 if (present(fldlist)) then
00193 call mct_rearr_rearrange_fldlist(av_cx, av_cc, Re_xxx2ccc, VECTOR=usevector, &
00194 ALLTOALL=usealltoall, fldlist=fldlist)
00195 else
00196 call mct_rearr_rearrange(av_cx, av_cc, Re_xxx2ccc, VECTOR=usevector, ALLTOALL=usealltoall)
00197 endif
00198 end if
00199
00200 end subroutine map_xxx2ccc_mct
00201
00202
00203
00204
00205 end module map_rofrof_mct