00001 module seq_cdata_mod
00002
00003
00004
00005 use shr_kind_mod , only: r8=> shr_kind_r8
00006 use shr_sys_mod , only: shr_sys_flush
00007 use shr_sys_mod , only: shr_sys_abort
00008 use seq_infodata_mod , only: seq_infodata_type
00009
00010 use mct_mod
00011 use seq_comm_mct
00012
00013 implicit none
00014 save
00015 private
00016
00017
00018
00019
00020
00021 public seq_cdata_init
00022 public seq_cdata_clean
00023 public seq_cdata_setptrs
00024 public seq_cdata_info
00025
00026
00027
00028
00029
00030
00031
00032
00033 type seq_cdata
00034
00035
00036
00037 character(len=16) :: name
00038 character(len=8) :: set
00039 integer :: ID
00040 integer :: mpicom
00041
00042
00043 type(mct_gGrid) ,pointer :: dom
00044 type(mct_gsMap) ,pointer :: gsMap
00045 type(seq_infodata_type),pointer :: infodata
00046 end type seq_cdata
00047 public seq_cdata
00048
00049
00050
00051
00052 character(*),parameter :: isset = 'set'
00053 character(*),parameter :: unset = 'NOT'
00054
00055
00056 contains
00057
00058
00059 subroutine seq_cdata_init(cdata,ID,dom,gsMap,infodata,name)
00060
00061 implicit none
00062
00063
00064
00065
00066 type(seq_cdata) ,intent(inout) :: cdata
00067 integer ,intent(in) :: ID
00068 type(mct_gGrid) ,intent(in),target :: dom
00069 type(mct_gsMap) ,intent(in),target :: gsMap
00070 type(seq_infodata_type)
00071 ,intent(in),target :: infodata
00072 character(len=*) ,intent(in),optional :: name
00073
00074
00075
00076 character(*),parameter :: subName = '(seq_cdata_init) '
00077 integer :: mpicom
00078 logical :: iamroot
00079
00080
00081 call seq_comm_setptrs(ID,mpicom=mpicom,iamroot=iamroot)
00082
00083 if (trim(cdata%set) == trim(isset)) then
00084 if (iamroot) write(logunit,*) trim(subName), &
00085 ': WARNING cdata is already set, cleaning'
00086 call seq_cdata_clean(cdata)
00087 endif
00088
00089 if (present(name)) then
00090 cdata%name = name
00091 else
00092 cdata%name = 'undefined'
00093 endif
00094
00095 cdata%set = isset
00096 cdata%ID = ID
00097 cdata%mpicom = mpicom
00098 cdata%dom => dom
00099 cdata%gsMap => gsMap
00100 cdata%infodata => infodata
00101
00102 end subroutine seq_cdata_init
00103
00104
00105
00106 subroutine seq_cdata_clean(cdata)
00107
00108 implicit none
00109
00110
00111
00112 type(seq_cdata),intent(inout) :: cdata
00113
00114
00115 character(*),parameter :: subName = '(seq_cdata_clean) '
00116
00117
00118
00119 if (trim(cdata%set) == trim(isset)) then
00120 cdata%name = 'cleaned'
00121 cdata%set = unset
00122 cdata%ID = -1
00123 cdata%mpicom = -1
00124 nullify(cdata%dom)
00125 nullify(cdata%gsMap)
00126 nullify(cdata%infodata)
00127 else
00128 cdata%set = unset
00129 cdata%ID = -1
00130 cdata%mpicom = -1
00131 endif
00132
00133 end subroutine seq_cdata_clean
00134
00135
00136
00137 subroutine seq_cdata_setptrs(cdata,ID,mpicom,dom,gsMap,infodata,name)
00138
00139 implicit none
00140
00141
00142
00143 type(seq_cdata),intent(in) :: cdata
00144
00145 integer ,optional :: ID
00146 integer ,optional :: mpicom
00147 type(mct_gGrid) ,optional,pointer :: dom
00148 type(mct_gsMap) ,optional,pointer :: gsMap
00149 type(seq_infodata_type)
00150 ,optional,pointer :: infodata
00151 character(len=*) ,optional :: name
00152
00153
00154 character(*),parameter :: subName = '(seq_cdata_setptrs) '
00155 logical :: iamroot
00156
00157
00158
00159 call seq_comm_setptrs(cdata%ID,iamroot=iamroot)
00160
00161 if (trim(cdata%set) == trim(unset)) then
00162 if (iamroot) write(logunit,*) trim(subName), &
00163 ': WARNING cdata is not set, return'
00164 return
00165 endif
00166
00167 if (present(name)) then
00168 name = cdata%name
00169 endif
00170 if (present(ID)) then
00171 ID = cdata%ID
00172 endif
00173 if (present(mpicom)) then
00174 mpicom = cdata%mpicom
00175 endif
00176 if (present(dom)) then
00177 dom => cdata%dom
00178 endif
00179 if (present(gsMap)) then
00180 gsMap => cdata%gsMap
00181 endif
00182 if (present(infodata)) then
00183 infodata => cdata%infodata
00184 endif
00185
00186 end subroutine seq_cdata_setptrs
00187
00188
00189
00190 subroutine seq_cdata_info(cdata)
00191
00192 implicit none
00193
00194
00195
00196 type(seq_cdata), intent(in) :: cdata
00197
00198
00199 character(*),parameter :: subName = '(seq_cdata_info) '
00200 logical :: iamroot
00201
00202
00203
00204 iamroot = .false.
00205 if (trim(cdata%set) == trim(isset)) then
00206 call seq_comm_setptrs(cdata%ID,iamroot=iamroot)
00207 else
00208 write(logunit,*) subName,':',' uninitialized'
00209 endif
00210
00211 if (iamroot) then
00212 write(logunit,*) ' '
00213 write(logunit,*) trim(subName),':'
00214 write(logunit,*) ' name = ',cdata%name
00215 write(logunit,*) ' ID = ',cdata%ID
00216 write(logunit,*) ' mpicom = ',cdata%mpicom
00217
00218
00219
00220
00221
00222
00223 write(logunit,*) ' gsMap gsize = ',mct_gsMap_gsize(cdata%gsMap)
00224 write(logunit,*) ' gsMap lsize = ',mct_gsMap_lsize(cdata%gsMap,cdata%mpicom)
00225 write(logunit,*) ' '
00226 endif
00227
00228 end subroutine seq_cdata_info
00229
00230 end module seq_cdata_mod