141 subroutine redistribute_solutions (SCATCI_input, solutions)
144 use mpi_gbl,
only: mpiint, mpi_mod_bcast
145 use options_module,
only: optionsset
146 use solutionhandler_module,
only: solutionhandler
147 use parallelization_module,
only: grid => process_grid
149 type(optionsset),
intent(in) :: SCATCI_input
150 type(solutionhandler),
allocatable,
intent(inout) :: solutions(:)
152 type(solutionhandler) :: oldsolution
153 integer(mpiint) :: srcrank
154 integer :: i, nnuc, nstat
157 if (grid % sequential)
return
160 do i = 1,
size(scatci_input % opts)
161 if (iand(scatci_input % opts(i) % vector_storage_method,
pass_to_cdenprop) /= 0 .and. &
166 srcrank = grid % group_master_world_rank(grid % which_group_is_work(i))
168 call mpi_mod_bcast(solutions(i) % core_energy, srcrank)
169 call mpi_mod_bcast(solutions(i) % vec_dimen, srcrank)
171 call mpi_mod_bcast(solutions(i) % ci_vec % nstat, srcrank)
172 call mpi_mod_bcast(solutions(i) % ci_vec % mgvn, srcrank)
173 call mpi_mod_bcast(solutions(i) % ci_vec % s, srcrank)
174 call mpi_mod_bcast(solutions(i) % ci_vec % sz, srcrank)
175 call mpi_mod_bcast(solutions(i) % ci_vec % nnuc, srcrank)
176 call mpi_mod_bcast(solutions(i) % ci_vec % e0, srcrank)
177 call mpi_mod_bcast(solutions(i) % ci_vec % CV_is_scalapack, srcrank)
178 call mpi_mod_bcast(solutions(i) % ci_vec % mat_dimen_r, srcrank)
179 call mpi_mod_bcast(solutions(i) % ci_vec % mat_dimen_c, srcrank)
181 nnuc = solutions(i) % ci_vec % nnuc
182 nstat = solutions(i) % ci_vec % nstat
184 if (.not.
allocated(solutions(i) % ci_vec % ei))
then
185 allocate (solutions(i) % ci_vec % ei(nstat))
188 call mpi_mod_bcast(solutions(i) % ci_vec % cname(1:nnuc), srcrank)
189 call mpi_mod_bcast(solutions(i) % ci_vec % charge(1:nnuc), srcrank)
190 call mpi_mod_bcast(solutions(i) % ci_vec % xnuc(1:nnuc), srcrank)
191 call mpi_mod_bcast(solutions(i) % ci_vec % ynuc(1:nnuc), srcrank)
192 call mpi_mod_bcast(solutions(i) % ci_vec % znuc(1:nnuc), srcrank)
193 call mpi_mod_bcast(solutions(i) % ci_vec % ei(1:nstat), srcrank)
197 call oldsolution % destroy()
198 oldsolution = solutions(i)
200 if (.not. grid % is_my_group_work(i))
then
201 oldsolution % ci_vec % blacs_context = -1
202 oldsolution % ci_vec % descr_CV_mat = -1
207 allocate (oldsolution % ci_vec % cv(0, 0))
212 solutions(i) % ci_vec % blacs_context = grid % wcntxt
213 solutions(i) % ci_vec % nprow = grid % wprows
214 solutions(i) % ci_vec % npcol = grid % wpcols
216 call solutions(i) % ci_vec % init_CV(int(oldsolution % ci_vec % mat_dimen_r), &
217 int(oldsolution % ci_vec % mat_dimen_c))
218 call solutions(i) % ci_vec % redistribute(oldsolution % ci_vec)
241 subroutine cdenprop_properties (SCATCI_input, iitf, solutions, properties_all)
243 use class_molecular_properties_data,
only: molecular_properties_data
244 use class_namelists,
only: cdenprop_namelists
246 use cdenprop_procs,
only: cdenprop_drv
247 use cdenprop_defs,
only: ir_max
248 use mpi_gbl,
only: master
249 use options_module,
only: optionsset
250 use solutionhandler_module,
only: solutionhandler
251 use timing_module,
only: master_timer
253 type(optionsset),
intent(in) :: SCATCI_input
254 integer,
intent(in) :: iitf
255 type(solutionhandler),
allocatable,
intent(inout) :: solutions(:)
256 type(molecular_properties_data),
intent(inout) :: properties_all
258 type(cdenprop_namelists) :: namelist_ij
259 type(civect) :: oldblock
261 integer :: i, j, ntgsym, ninputs, maxpole, nblock, mxstat
263 ninputs =
size(scatci_input % opts)
267 if (.not. scatci_input % interface_opts(iitf) % write_dip .and. &
268 .not. scatci_input % interface_opts(iitf) % write_rmt)
return
271 call properties_all % clean
272 call properties_all % preallocate_property_blocks(ninputs**2 * (maxpole + 1)**2)
273 properties_all % dense_blocks(:) % mat_dimen = 0
276 sym_i_loop:
do i = 1, ninputs
277 if (iand(scatci_input % opts(i) % vector_storage_method,
pass_to_cdenprop) /= 0 .and. &
280 sym_j_loop:
do j = i, ninputs
281 if (iand(scatci_input % opts(j) % vector_storage_method,
pass_to_cdenprop) /= 0 .and. &
285 if (i == j .and. .not. scatci_input % interface_opts(iitf) % all_props) cycle
288 call namelist_ij % init(2)
291 namelist_ij % lucsf(1:2) = (/ scatci_input % opts(i) % megul, &
292 scatci_input % opts(j) % megul /)
293 namelist_ij % nciset(1:2) = (/ scatci_input % opts(i) % output_ci_set_number, &
294 scatci_input % opts(j) % output_ci_set_number /)
295 namelist_ij % nstat = 0
296 namelist_ij % lupropw = 0
297 namelist_ij % lucivec = 0
298 namelist_ij % numtgt = 0
299 namelist_ij % lutdip = scatci_input % interface_opts(iitf) % lutdip
300 namelist_ij % ukrmolp_ints = scatci_input % opts(i) % use_UKRMOL_integrals
301 namelist_ij % luprop = merge(scatci_input % opts(i) % integral_unit, &
302 scatci_input % interface_opts(iitf) % luprop, &
303 scatci_input % interface_opts(iitf) % luprop < 0)
304 namelist_ij % isw = scatci_input % interface_opts(iitf) % isw
306 ntgsym = scatci_input % opts(i) % num_target_sym
309 if (scatci_input % opts(i) % ci_target_flag ==
no_ci_target)
then
310 namelist_ij % max_multipole = 2
312 namelist_ij % max_multipole = 1
313 namelist_ij % numtgt(1:ntgsym) = scatci_input % opts(i) % num_target_state_sym(1:ntgsym)
314 namelist_ij % itarget_spin(1:ntgsym) = scatci_input % interface_opts(iitf) % itspin(1:ntgsym)
318 solutions(j) % ci_vec % blacs_context = solutions(i) % ci_vec % blacs_context
319 solutions(j) % ci_vec % descr_CV_mat(2) = solutions(i) % ci_vec % descr_CV_mat(2)
322 call master_timer % start_timer(
"Cdenprop")
323 call cdenprop_drv(solutions(i) % ci_vec, solutions(j) % ci_vec, namelist_ij, properties_all)
324 call master_timer % stop_timer(
"Cdenprop")
325 call master_timer % report_timers
328 call namelist_ij % dealloc
337 properties_all % swintf_format = .true.
340 if (scatci_input % interface_opts(iitf) % write_dip .and. properties_all % no_symmetries > 0)
then
341 if (scatci_input % interface_opts(iitf) % all_props)
call properties_all % sort_by_energy
342 call properties_all % write_properties(scatci_input % interface_opts(iitf) % lupropw, &
343 scatci_input % opts(1) % use_UKRMOL_integrals)
347 if (scatci_input % interface_opts(iitf) % write_rmt)
then
348 nblock = properties_all % no_blocks
349 mxstat = max(maxval(properties_all % dense_blocks(1:nblock) % mat_dimen_r), &
350 maxval(properties_all % dense_blocks(1:nblock) % mat_dimen_c))
352 if (properties_all % dense_blocks(i) % mat_dimen_r /= mxstat .or. &
353 properties_all % dense_blocks(i) % mat_dimen_c /= mxstat)
then
354 oldblock = properties_all % dense_blocks(i)
355 call properties_all % dense_blocks(i) % init_CV(mxstat, mxstat)
356 properties_all % dense_blocks(i) % CV = 0
357 call properties_all % dense_blocks(i) % redistribute(oldblock)
358 call oldblock % final_CV
360 properties_all % dense_blocks(i) % mat_dimen = max(properties_all % dense_blocks(i) % mat_dimen_r, &
361 properties_all % dense_blocks(i) % mat_dimen_c)
689 subroutine get_channel_info (this, opts, prop)
691 use algorithms,
only: findloc
692 use class_molecular_properties_data,
only: molecular_properties_data
693 use const_gbl,
only: stdout
694 use global_utils,
only: mprod
695 use mpi_gbl,
only: mpi_xermsg
696 use options_module,
only: options
697 use precisn,
only: wp
698 use ukrmol_interface_gbl,
only: ukp_preamp
700 class(outerinterface),
intent(inout) :: this
701 type(options),
intent(in) :: opts
702 type(molecular_properties_data),
intent(in) :: prop
704 integer :: i, j, k, mgvn, spin, tgt_symm, tgt_mgvn, tgt_spin, nch, prj_mgvn, congen_tgt_id, denprop_tgt_id, isym
705 real(wp) :: tgt_enrg, ebase
707 ebase = prop % energies(1)
709 spin = nint(2 * opts % spin + 1)
711 this % maxnmo = sum(opts % num_orbitals_sym)
715 if (.not.
allocated(this % idtarg))
then
716 this % ntarg = opts % total_num_target_states
717 allocate (this % idtarg(this % ntarg))
720 congen_symm_loop:
do j = 1,
size(opts % num_target_state_sym)
721 congen_targ_loop:
do k = 1, opts % num_target_state_sym(j)
722 congen_tgt_id = congen_tgt_id + 1
724 tgt_mgvn = opts % target_spatial(congen_tgt_id)
725 tgt_spin = opts % target_multiplicity(congen_tgt_id)
726 denprop_targ_loop:
do i = 1, prop % no_states
727 isym = prop % energies_index(2, i)
728 if (prop % symmetries_index(1, isym) == tgt_mgvn .and. &
729 prop % symmetries_index(2, isym) == tgt_spin)
then
730 denprop_tgt_id = denprop_tgt_id + 1
732 if (denprop_tgt_id == k)
then
733 this % idtarg(congen_tgt_id) = i
734 exit denprop_targ_loop
736 end do denprop_targ_loop
737 end do congen_targ_loop
738 end do congen_symm_loop
739 if (any(this % idtarg == -1))
then
740 call mpi_xermsg(
'Postprocessing_module',
'get_channel_info',
'Property file not compatible with target symmetries&
741 &given in the SCATCI input file.', 1, 1)
745 write (stdout,
'(/,1x,"Target state indices sorted by energy (IDTARG): ")')
746 write (stdout,
'( 1x,20I4)') this % idtarg
748 do i = 1, prop % no_states
751 if (findloc(this % idtarg, i, 1) == 0) cycle
754 tgt_symm = prop % energies_index(2, i)
755 tgt_mgvn = prop % symmetries_index(1, tgt_symm)
756 tgt_spin = prop % symmetries_index(2, tgt_symm)
757 tgt_enrg = prop % energies(i)
760 if (abs(spin - tgt_spin) /= 1) cycle
763 prj_mgvn = mprod(tgt_mgvn + 1, mgvn + 1, 0, stdout)
766 if (opts % use_UKRMOL_integrals)
then
767 call ukp_preamp(prj_mgvn, this % nchan + 1, this % lchl, this % mchl, this % qchl, nch, this % maxnmo)
769 call mpi_xermsg(
'Postprocessing_module',
'get_channel_info', &
770 'Interface for SWINTERF integrals not implemented.', 1, 1)
775 this % ichl(this % nchan + j) = i
776 this % echl(this % nchan + j) = 2 * (tgt_enrg - ebase)
777 this % irrchl(this % nchan + j) = prj_mgvn
781 this % nchan = this % nchan + nch
785 write (stdout,
'(/," Channel Target l m q Irr Energy Energy(eV)")')
787 do i = 1, this % nchan
788 write (stdout,
'(I5,I8,I5,2I3,2x,A4,I3,2F10.6)') i, this % ichl(i), this % lchl(i), this % mchl(i), this % qchl(i), &
789 'N/A', this % irrchl(i), this % echl(i), this % echl(i) / 0.073500d0
817 subroutine get_boundary_data (this, opts, prop, solution)
819 use algorithms,
only: findloc
820 use class_molecular_properties_data,
only: molecular_properties_data
821#if defined(usempi) && defined(scalapack)
822 use cdenprop_defs,
only: blacs_get, blacs_gridinit
824 use const_gbl,
only: stdout
825 use global_utils,
only: mprod
826 use mpi_gbl,
only: master, myrank, mpi_xermsg
827 use options_module,
only: options
828 use solutionhandler_module,
only: solutionhandler
829 use ukrmol_interface_gbl,
only: eval_amplitudes, ukp_readamp
831 class(outerinterface),
intent(inout) :: this
832 type(options),
intent(in) :: opts
833 type(molecular_properties_data),
intent(in) :: prop
834 type(solutionhandler),
intent(in) :: solution
836 type(civect) :: orb_amps, dist_orb_amps
838 integer,
allocatable :: idchl(:), nvo(:), tgcontirr(:)
839 real(wp),
allocatable :: ampls(:)
841 integer :: i, j, k, ir, ncontmo(8), iprnt = 0, nchan, nstat, norbs, morbs, ncnt, offs, totirr, tgtirr
844 nstat = solution % ci_vec % nstat
845 morbs = maxval(opts % num_orbitals_sym)
846 norbs = dot_product(opts % num_target_state_sym, opts % num_continuum_orbitals_target)
848 allocate(ampls(morbs), idchl(nchan), tgcontirr(this % ntarg), nvo(opts % num_syms))
852 do j = 1, this % ntarg
854 if (this % ichl(i) == this % idtarg(j))
then
859 totirr = opts % lambda + 1
860 tgtirr = prop % symmetries_index(1, prop % energies_index(2, j)) + 1
861 tgcontirr(j) = mprod(totirr, tgtirr, 0, stdout)
864 write (stdout,
'(/,1x,"Channel target state energy map (IDCHL): ")')
865 write (stdout,
'( 1x,20I5)') idchl
870 orb_amps % blacs_context = -1
871 orb_amps % CV_is_scalapack = solution % ci_vec % CV_is_scalapack
872#if defined(usempi) && defined(scalapack)
873 if (orb_amps % CV_is_scalapack)
then
874 call blacs_get(-1_blasint, 0_blasint, orb_amps % blacs_context)
875 call blacs_gridinit(orb_amps % blacs_context,
'R', 1_blasint, 1_blasint)
878 call orb_amps % init_CV(nchan, norbs)
881 if (.not.
allocated(this % wamp))
then
882 allocate (this % wamp(this % nfdm + 1))
886 this % wamp(:) % nprow = solution % ci_vec % nprow
887 this % wamp(:) % npcol = solution % ci_vec % npcol
888 this % wamp(:) % blacs_context = solution % ci_vec % blacs_context
889 this % wamp(:) % CV_is_scalapack = solution % ci_vec % CV_is_scalapack
892 do ir = 1, this % nfdm + 1
893 call this % wamp(ir) % init_CV(nchan, nstat)
897 do ir = 1, this % nfdm + 1
900 if (myrank == master)
then
902 call eval_amplitudes(this % r_points(ir), .false.)
903 call ukp_readamp(orb_amps % CV, this % nchan, this % irrchl, this % lchl, this % mchl, this % qchl, ncontmo, &
904 opts % lambda_continuum_orbitals_target, iprnt)
908 if (this % auto_nvo)
then
909 nvo(1 : opts % num_syms) = opts % num_orbitals_sym(1 : opts % num_syms) &
910 - opts % num_target_orbitals_sym(1 : opts % num_syms) &
911 - ncontmo(1 : opts % num_syms)
917 write (stdout,
'(/,1x,"Virtual orbitals per CI target continuum spin-symmetry: ")')
918 write (stdout,
'(*(I4))') pack(nvo, [ (findloc(tgcontirr, i, 1) /= 0, i = 1, opts % num_syms) ])
919 write (stdout,
'(/,1x,"Virtual orbitals per CI target state continuum in energy order (NVO): ")')
920 write (stdout,
'(20I4)') nvo(tgcontirr)
923 if (any(nvo(tgcontirr) < 0))
then
924 call mpi_xermsg(
'Postprocessing_module',
'get_boundary_data', &
925 'Some NVOs are negative. This looks like incorrect setup of continuum orbitals.', 1, 1)
939 else if (this % ichl(j) /= this % ichl(idchl(i - 1)))
then
942 offs = offs + ncnt + nvo(k)
945 ampls(1:ncnt) = orb_amps % CV(j, 1:ncnt)
946 orb_amps % CV(j, 1:norbs) = 0
947 orb_amps % CV(j, offs + 1:offs + ncnt) = ampls(1:ncnt)
952 if (.not. solution % ci_vec % CV_is_scalapack)
then
953 call this % wamp(ir) % A_B_matmul(orb_amps, solution % ci_vec,
'N',
'N')
956 dist_orb_amps % nprow = solution % ci_vec % nprow
957 dist_orb_amps % npcol = solution % ci_vec % npcol
958 dist_orb_amps % blacs_context = solution % ci_vec % blacs_context
959 dist_orb_amps % CV_is_scalapack = solution % ci_vec % CV_is_scalapack
960 call dist_orb_amps % init_CV(nchan, norbs)
961 call dist_orb_amps % redistribute(orb_amps)
964 call this % wamp(ir) % A_B_matmul(dist_orb_amps, solution % ci_vec,
'N',
'N')
968 if (ir < this % nfdm + 1)
then
969 this % wamp(ir) % CV = sqrt(2.0_wp) * this % wamp(ir) % CV
991 subroutine write_channel_info (this, nchset, opts, luchan, cform, prop)
993 use algorithms,
only: findloc
994 use class_molecular_properties_data,
only: molecular_properties_data
995 use consts,
only: amu
997 use mpi_gbl,
only: myrank, master
998 use options_module,
only: options
1000 class(outerinterface),
intent(in) :: this
1001 integer,
intent(in) :: nchset, luchan
1002 type(options),
intent(in) :: opts
1003 character(len=1),
intent(in) :: cform
1005 type(molecular_properties_data),
intent(in) :: prop
1007 integer,
parameter :: keych = 10
1009 integer :: i, k, nvd, nrec, ninfo, ndata, nvib, ndis, stot, gutot, ntarg, ivtarg(1), iv(1), ion, mtarg, starg, gutarg, nnuc
1011 real(wp) :: r, rmass, etarg
1013 if (myrank /= master)
return
1015 nnuc = prop % no_nuclei
1020 if (opts % use_UKRMOL_integrals)
then
1021 ion = nint(sum(prop % charge(1:nnuc) - this % core_charges(1:nnuc))) - (opts % num_electrons - 1)
1023 ion = nint(sum(prop % charge(1:nnuc))) - (opts % num_electrons - 1)
1027 ntarg = this % ntarg
1028 stot = nint(2 * opts % spin + 1)
1029 rmass = sum(1 / prop % mass(1:nnuc), prop % mass(1:nnuc) > 0)
1036 nrec = 3 + ntarg + this % nchan + nvd
1038 ndata = nrec - ninfo
1040 if (cform ==
'F')
then
1041 write (luchan,
'(16I5)') keych, nchset, nrec, ninfo, ndata
1042 write (luchan,
'(A80)') opts % diag_name
1043 write (luchan,
'(16I5)') ntarg, nvib, ndis, this % nchan
1044 write (luchan,
'(4I5,2D20.12)') opts % lambda, stot, gutot, ion, r, rmass
1047 do i = 1, prop % no_states
1048 if (findloc(this % idtarg, i, 1) /= 0)
then
1050 isymm = prop % energies_index(2, i)
1051 mtarg = prop % symmetries_index(1, isymm)
1052 starg = prop % symmetries_index(2, isymm)
1054 etarg = prop % energies(i)
1055 write (luchan,
'(4I5,2D20.12)') k, mtarg, starg, gutarg, etarg
1058 do i = 1, this % nchan
1059 write (luchan,
'(4I5,2D20.12)') i, this % ichl(i), this % lchl(i), this % mchl(i), this % echl(i)
1062 write (luchan,
'(16I5)') i, ivtarg(i), iv(i)
1065 write (luchan) keych, nchset, nrec, ninfo, ndata
1066 write (luchan) opts % diag_name(1:80)
1067 write (luchan) ntarg, nvib, ndis, this % nchan
1068 write (luchan) opts % lambda, stot, gutot, ion, r, rmass
1071 do i = 1, prop % no_states
1072 if (findloc(this % idtarg, i, 1) > 0)
then
1074 isymm = prop % energies_index(2, i)
1075 mtarg = prop % symmetries_index(1, isymm)
1076 starg = prop % symmetries_index(2, isymm)
1078 etarg = prop % energies(i)
1079 write (luchan) k, mtarg, starg, gutarg, etarg
1082 do i = 1, this % nchan
1083 write (luchan) i, this % ichl(i), this % lchl(i), this % mchl(i), this % echl(i)
1086 write (luchan) i, ivtarg(i), iv(i)
1117 subroutine write_boundary_data (this, nrmset, opts, lurmt, rform, prop, solution)
1119 use class_molecular_properties_data,
only: molecular_properties_data
1120 use consts,
only: amu
1122 use mpi_gbl,
only: myrank, master
1123 use precisn_gbl,
only: wp_bytes
1124 use options_module,
only: options
1125 use solutionhandler_module,
only: solutionhandler
1127 class(outerinterface),
intent(in) :: this
1128 integer,
intent(in) :: nrmset, lurmt
1129 type(options),
intent(in) :: opts
1130 character(len=1),
intent(in) :: rform
1131 type(molecular_properties_data),
intent(in) :: prop
1132 type(solutionhandler),
intent(in) :: solution
1134 integer,
parameter :: keyrm = 11
1135 character(len=10) :: io_msg
1136 type(civect) :: wamp
1138 integer :: i, j, k, nchsq, nrec, ninfo, ndata, ntarg, nvib, ndis, nchan, stot, gutot, ion, ibut, iex, nocsf, npole, nnuc
1139 integer :: ismax, nstat, io_stat, v_list(0)
1140 logical :: intel_bug_workaround
1141 real(wp) :: r, rmass, rmatr
1143 nnuc = prop % no_nuclei
1149 rmatr = this % rmatr
1150 ntarg = this % ntarg
1151 nstat = solution % ci_vec % nstat
1154 nchan = this % nchan
1155 stot = nint(2 * opts % spin + 1)
1158 if (opts % use_UKRMOL_integrals)
then
1159 ion = nint(sum(prop % charge(1:nnuc) - this % core_charges(1:nnuc))) - (opts % num_electrons - 1)
1161 ion = nint(sum(prop % charge(1:nnuc))) - (opts % num_electrons - 1)
1165 nchsq = nchan * (nchan + 1) / 2
1167 rmass = sum(1 / prop % mass(1:nnuc), prop % mass(1:nnuc) > 0)
1173 if (rform ==
'F')
then
1174 if (ismax > 0) nrec = nrec + (nchsq * ismax + 3) / 4
1175 nrec = nrec + (nstat + 3) / 4
1176 nrec = nrec + (nchan * nstat + 3) / 4
1177 if (npole > 0) nrec = nrec + (nocsf * npole + 3) / 4
1178 if (ibut > 0) nrec = nrec + (3 * nchan + 3) / 4
1179 if (abs(ibut) > 1) nrec = nrec + 1 + (nchan + 3) / 4 + (iex + 3) / 4 + (nchan * iex + 3) / 4
1182 if (ismax > 0) nrec = nrec + 1
1183 if (npole > 0) nrec = nrec + 1
1184 if (ibut > 0) nrec = nrec + 1
1185 if (abs(ibut) > 1) nrec = nrec + 4
1189 ndata = nrec - ninfo
1190 intel_bug_workaround = .false.
1192#ifdef __INTEL_COMPILER
1195 if (nchan*nstat > 2**30/wp_bytes)
then
1196 intel_bug_workaround = .true.
1199 wamp % blacs_context = -1
1200 wamp % CV_is_scalapack = this % wamp(this % nfdm + 1) % CV_is_scalapack
1201#if defined(usempi) && defined(scalapack)
1202 if (wamp % CV_is_scalapack)
then
1203 call blacs_get(-1_blasint, 0_blasint, wamp % blacs_context)
1204 call blacs_gridinit(wamp % blacs_context,
'R', 1_blasint, 1_blasint)
1207 call wamp % init_CV(nchan, nstat)
1211 if (rform ==
'F')
then
1212 if (myrank == master)
then
1213 write (lurmt,
'(10I7)') keyrm, nrmset, nrec, ninfo, ndata
1214 write (lurmt,
'(A80)') opts % diag_name
1215 write (lurmt,
'(16I5)') ntarg, nvib, ndis, nchan
1216 write (lurmt,
'(4I5,2D20.13)') opts % lambda, stot, gutot, ion, r, rmass
1217 write (lurmt,
'(4I5,2D20.13)') ismax, nstat, npole, ibut, rmatr
1219 if (ismax > 0)
write(lurmt,
'(4D20.13)') ((this % a(i,k),i=1,nchsq),k=1,ismax)
1220 write (lurmt,
'(4D20.13)') (solution % ci_vec % ei(i) + solution % core_energy,i=1,nstat)
1221 if (intel_bug_workaround)
then
1222 call wamp % redistribute(this%wamp(this%nfdm + 1), this%wamp(this%nfdm + 1)%blacs_context)
1223 write (lurmt,
'(4D20.13)') wamp % CV(1:nchan, 1:nstat)
1225 write (lurmt,
'(dt(4,20,13))') this % wamp(this % nfdm + 1)
1233 if (intel_bug_workaround)
then
1235 call wamp % redistribute(this%wamp(this%nfdm + 1), this%wamp(this%nfdm + 1)%blacs_context)
1238 call this % wamp(this % nfdm + 1) % formatted_write(-1,
'', v_list, io_stat, io_msg)
1242 if (myrank == master)
then
1243 write(lurmt) keyrm, nrmset, nrec, ninfo, ndata
1244 write(lurmt) opts % diag_name(1:80)
1245 write(lurmt) ntarg, nvib, ndis, nchan
1246 write(lurmt) opts % lambda, stot, gutot, ion, r, rmass
1247 write(lurmt) ismax, nstat, npole, ibut, rmatr
1249 if (ismax > 0)
write(lurmt) ((this % a(i,k),i=1,nchsq),k=1,ismax)
1250 write (lurmt) (solution % ci_vec % ei(i) + solution % core_energy,i=1,nstat)
1251 if (intel_bug_workaround)
then
1252 call wamp % redistribute(this%wamp(this%nfdm + 1), this%wamp(this%nfdm + 1)%blacs_context)
1253 write (lurmt) wamp % CV(1:nchan, 1:nstat)
1255 write (lurmt) this % wamp(this % nfdm + 1)
1263 if (intel_bug_workaround)
then
1265 call wamp % redistribute(this%wamp(this%nfdm + 1), this%wamp(this%nfdm + 1)%blacs_context)
1268 call this % wamp(this % nfdm + 1) % unformatted_write(-1, io_stat, io_msg)
1309 subroutine get_channel_couplings (this, ismax, ntarg, target_properties, alpha0, alpha2, use_pol)
1311 use coupling_obj_gbl,
only: couplings_type
1312 use class_molecular_properties_data,
only: molecular_properties_data
1313 use mpi_gbl,
only: mpi_xermsg
1314 use precisn,
only: wp
1316 class(outerinterface),
intent(inout) :: this
1317 type(molecular_properties_data),
intent(in) :: target_properties
1319 integer,
intent(in) :: ismax, ntarg
1320 real(wp),
intent(in) :: alpha0, alpha2
1321 logical,
intent(in) :: use_pol
1323 real(wp),
parameter :: fourpi = 12.5663706143591729538505735331180115_wp
1324 real(wp),
parameter :: roneh = 0.70710678118654752440084436210484903_wp
1325 real(wp),
parameter :: rothree = 0.57735026918962576450914878050195745_wp
1331 real(wp),
parameter :: x2_X00 = 0.282094791773878e+00_wp
1332 real(wp),
parameter :: x2_X20 = -0.126156626101008e+00_wp
1333 real(wp),
parameter :: x2_X22 = 0.218509686118416e+00_wp
1335 real(wp),
parameter :: y2_X00 = 0.282094791773878e+00_wp
1336 real(wp),
parameter :: y2_X20 = -0.126156626101008e+00_wp
1337 real(wp),
parameter :: y2_X22 = -0.218509686118416e+00_wp
1339 real(wp),
parameter :: z2_X00 = 0.282094791773878e+00_wp
1340 real(wp),
parameter :: z2_X20 = 0.252313252202016e+00_wp
1342 type(couplings_type) :: couplings
1344 real(wp),
allocatable :: prop(:,:,:)
1346 real(wp) :: cpl, sph_cpl, fac
1347 integer :: l1, m1, q1, l2, m2, q2, no_cpl, lqt, isq, it1, it2
1348 integer :: ch_1, ch_2, lambda, mlambda, lmin, lmax
1349 logical :: use_alpha2
1351 if (use_pol .and. ntarg > 1)
then
1352 write (*,
'("WARNING: adding polarization potential while more than one target state is present in the outer region.")')
1356 call target_properties % decompress(1, ismax, prop)
1359 use_alpha2 = (use_pol .and. alpha2 /= 0.0_wp)
1360 lmax = merge(max(ismax, 3), ismax, use_pol)
1361 no_cpl = this % nchan * (this % nchan + 1) / 2
1364 if (
allocated(this % a))
deallocate (this % a)
1365 allocate (this % a(no_cpl, lmax))
1366 this % a(:,:) = 0.0_wp
1368 do ch_1 = 1, this % nchan
1370 l1 = this % lchl(ch_1)
1371 m1 = this % mchl(ch_1)
1372 q1 = this % qchl(ch_1)
1374 it1 = this % ichl(ch_1)
1378 l2 = this % lchl(ch_2)
1379 m2 = this % mchl(ch_2)
1380 q2 = this % qchl(ch_2)
1382 it2 = this % ichl(ch_2)
1386 call couplings % bounds_rg(l1, l2, m1, m2, lmin, lmax)
1389 if (lmax > ismax) lmax = ismax
1393 if (lmin == 0) lmin = 2
1396 lqt = ch_1 * (ch_1 - 1) / 2 + ch_2
1400 do lambda = lmin, lmax, 2
1404 fac = sqrt(fourpi / (2 * lambda + 1.0_wp))
1406 do mlambda = -lambda, lambda
1412 cpl = 2.0_wp * fac * couplings % rgaunt(l1, lambda, l2, m1, mlambda, m2)
1416 isq = lambda * lambda + lambda + mlambda
1420 this % a(lqt, lambda) = this % a(lqt, lambda) + cpl * prop(it1, it2, isq)
1427 if (use_pol .and. it1 == 1 .and. it2 == 1)
then
1433 if (l1 == l2 .and. m1 == m2)
then
1435 write(*,
'("Spherical part of the polarization potential will be added to the &
1436 &channel (target state,l,m), coefficient value: (",3i5,") ",e25.15)') &
1437 it1, l1, m1, -sph_cpl * alpha0
1438 this % a(lqt, lambda) = this % a(lqt, lambda) - sph_cpl * alpha0
1448 if (use_alpha2)
then
1450 write(*,
'("Non-spherical part of the polarization potential &
1451 &(target state,l1,m2,l2,m2): ",5i5)') it1, l1, m1, l2, m2
1454 cpl = x2_x00 * couplings % rgaunt(l1, 0, l2, m1, 0, m2) + &
1455 x2_x20 * couplings % rgaunt(l1, 2, l2, m1, 0, m2) + &
1456 x2_x22 * couplings % rgaunt(l1, 2, l2, m1, 2, m2)
1457 write(*,
'("x^2 coefficient: ",e25.15)') -cpl * alpha2
1458 this % a(lqt, lambda) = this % a(lqt, lambda) - cpl * alpha2
1461 cpl = y2_x00 * couplings % rgaunt(l1, 0, l2, m1, 0, m2) + &
1462 y2_x20 * couplings % rgaunt(l1, 2, l2, m1, 0, m2) + &
1463 y2_x22 * couplings % rgaunt(l1, 2, l2, m1, 2, m2)
1464 write(*,
'("y^2 coefficient: ",e25.15)') -cpl * alpha2
1465 this % a(lqt, lambda) = this % a(lqt, lambda) - cpl * alpha2
1468 cpl = z2_x00 * couplings % rgaunt(l1, 0, l2, m1, 0, m2) + &
1469 z2_x20 * couplings % rgaunt(l1, 2, l2, m1, 0, m2)
1470 write(*,
'("z^2 coefficient: ",e25.15)') -cpl * alpha2
1471 this % a(lqt, lambda) = this % a(lqt, lambda) - cpl * alpha2
1474 cpl = couplings % rgaunt(l1, 2, l2, m1, 1, m2) * rothree
1475 write(*,
'("xz coefficient: ",e25.15)') -cpl * alpha2
1476 this % a(lqt, lambda) = this % a(lqt, lambda) - cpl * alpha2
1479 cpl = couplings % rgaunt(l1, 2, l2, m1, -1, m2) * rothree
1480 write(*,
'("yz coefficient: ",e25.15)') -cpl * alpha2
1481 this % a(lqt, lambda) = this % a(lqt, lambda) - cpl * alpha2
1484 cpl = couplings % rgaunt(l1, 2, l2, m1, -2, m2) * rothree
1485 write(*,
'("xy coefficient: ",e25.15)') -cpl * alpha2
1486 this % a(lqt, lambda) = this % a(lqt, lambda) - cpl * alpha2
1543 subroutine write_rmt_data (input, iitf, inner_properties, solutions, intf)
1545 use algorithms,
only: findloc, insertion_sort
1546 use class_molecular_properties_data,
only: molecular_properties_data
1547 use const_gbl,
only: stdout
1549 use mpi_gbl,
only: myrank, master, mpiint, mpi_xermsg, mpi_mod_file_open_write, &
1550 mpi_mod_file_close, mpi_mod_file_set_size, mpi_mod_file_write, mpi_mod_barrier
1551 use options_module,
only: optionsset
1552 use timing_module,
only: master_timer
1553 use solutionhandler_module,
only: solutionhandler
1555 type(optionsset),
intent(in) :: input
1556 integer,
intent(in) :: iitf
1557 type(molecular_properties_data),
intent(in) :: inner_properties
1558 type(solutionhandler),
allocatable,
intent(in) :: solutions(:)
1559 type(outerinterface),
allocatable,
intent(in) :: intf(:)
1561 real(rmt_real),
allocatable :: cf(:,:), crlv(:,:), etarg(:), rg(:), eig(:), r_points(:)
1562 integer(rmt_int),
allocatable :: iidip(:), ifdip(:), lm_rg(:,:), ltarg(:), starg(:), nconat(:), l2p(:), m2p(:), ichl(:), &
1564 integer,
allocatable :: ions(:)
1566 type(molecular_properties_data) :: target_properties
1568 type(civect) :: wmat
1569 real(rmt_real) :: bbloch = 0, prop, rmatr, delta_r
1570 integer :: i, j, k, l, m, irr_map(8,8), u, v, nsymm, ind, ip, irr1, irr2, it1, it2, nnuc, &
1571 ierr, nblock, sym1, sym2, ref
1572 integer(mpiint) :: fh
1573 integer(rmt_int) :: s1, s2, ntarg, n_rg, nelc, nz, lamax, inast, nchmx, nstmx, lmaxp1, nchan, lrgl, nspn, npty, &
1574 mnp1, mxstat, lrang2, lmax, nfdm
1576 call target_properties % read_properties(input % interface_opts(iitf) % lutdip, 1)
1579 inast = count(iand(input % opts(:) % vector_storage_method,
pass_to_cdenprop) /= 0 .and. &
1582 ref = maxloc(intf(:) % ntarg, 1)
1583 nnuc = target_properties % no_nuclei
1584 nfdm = input % interface_opts(iitf) % nfdm
1585 delta_r = input % interface_opts(iitf) % delta_r
1586 rmatr = input % interface_opts(iitf) % rmatr
1587 nsymm =
size(input % opts(:))
1588 ntarg = intf(ref) % ntarg
1589 nelc = input % opts(1) % num_electrons - 1
1590 mxstat = maxval(inner_properties % dense_blocks(1:inner_properties % no_blocks) % mat_dimen)
1593 if (nsymm == 0 .or. inast == 0 .or. ntarg == 0 .or. mxstat <= 0)
then
1594 write (stdout, *)
'Nothing to do in RMT interface'
1598 nz = sum(target_properties % charge(1:nnuc) - intf(ref) % core_charges(1:nnuc))
1605 call master_timer % start_timer(
"RMT interface")
1608 ions = intf(ref) % idtarg
1609 call insertion_sort(ions)
1612 call mpi_mod_file_open_write(
'molecular_data', fh, ierr)
1613 call mpi_mod_file_set_size(fh, 0)
1615 allocate (propblocks(inner_properties % no_blocks))
1617 write (stdout,
'(/,"Writing RMT data file")')
1618 write (stdout,
'( "=====================")')
1619 write (stdout,
'(/," Inner region dipole block max size: ",I0)') mxstat
1620 write (stdout,
'(/," Ionic states used in outer region: ")')
1621 write (stdout,
'(/," ",20I5)') ions
1629 do ip = 1, inner_properties % no_blocks
1630 if (inner_properties % dense_index(3, ip) == 1 .and. &
1631 inner_properties % dense_index(4, ip) == m)
then
1632 sym1 = inner_properties % dense_index(1, ip)
1633 sym2 = inner_properties % dense_index(2, ip)
1634 irr1 = inner_properties % symmetries_index(1, sym1) + 1
1635 irr2 = inner_properties % symmetries_index(1, sym2) + 1
1637 propblocks(nblock) = ip
1638 irr_map(irr1, irr2) = nblock
1643 if (
allocated(iidip))
deallocate (iidip)
1644 if (
allocated(ifdip))
deallocate (ifdip)
1645 allocate (iidip(nblock))
1646 allocate (ifdip(nblock))
1652 sym1 = inner_properties % dense_index(1, propblocks(ip))
1653 sym2 = inner_properties % dense_index(2, propblocks(ip))
1654 irr1 = inner_properties % symmetries_index(1, sym1) + 1
1655 irr2 = inner_properties % symmetries_index(1, sym2) + 1
1661 call mpi_mod_file_write(fh, int(nblock, rmt_int))
1662 call mpi_mod_file_write(fh, mxstat)
1663 call mpi_mod_file_write(fh, mxstat)
1664 call mpi_mod_file_write(fh, iidip, nblock)
1665 call mpi_mod_file_write(fh, ifdip, nblock)
1669 call inner_properties % dense_blocks(propblocks(ip)) % stream_write(fh)
1675 if (iand(input % opts(i) % vector_storage_method,
pass_to_cdenprop) /= 0 .and. &
1677 if (intf(i) % nchan > 0)
then
1678 lrang2 = max(int(lrang2), maxval(intf(i) % lchl(1:intf(i) % nchan)))
1679 lamax = max(int(lamax), intf(i) % ismax)
1680 nchmx = max(int(nchmx), intf(i) % nchan)
1682 nstmx = max(int(nstmx), solutions(i) % vec_dimen)
1689 call mpi_mod_file_write(fh, ntarg)
1692 if (myrank == master)
then
1693 allocate (etarg(ntarg), ltarg(ntarg), starg(ntarg), nconat(ntarg), l2p(nchmx), m2p(nchmx), eig(nstmx), &
1694 cf(nchmx, nchmx), ichl(nchmx), crlv(ntarg, ntarg), r_points(nfdm + 1), stat = ierr)
1696 allocate (etarg(0), ltarg(0), starg(0), nconat(0), l2p(0), m2p(0), eig(0), rg(0), lm_rg(0, 0), &
1697 cf(0, 0), ichl(0), crlv(0, 0), r_points(0), stat = ierr)
1700 call mpi_xermsg(
'Postprocessing_module',
'write_rmt_data',
'Memory allocation failure.', 1, 1)
1706 wmat % blacs_context = intf(1) % wamp(nfdm + 1) % blacs_context
1707 wmat % CV_is_scalapack = intf(1) % wamp(nfdm + 1) % CV_is_scalapack
1708 call wmat % init_CV(int(nchmx), int(nstmx))
1711 if (myrank == master)
then
1713 etarg(i) = target_properties % energies(ions(i))
1714 ltarg(i) = target_properties % symmetries_index(1, target_properties % energies_index(2, ions(i))) + 1
1715 starg(i) = target_properties % symmetries_index(2, target_properties % energies_index(2, ions(i)))
1720 if (myrank == master)
then
1722 r_points(i) = rmatr - (nfdm + 1 - i) * delta_r
1728 if (myrank == master)
then
1730 do ip = 1, target_properties % non_zero_properties
1731 if (target_properties % properties_index(3, ip) == 1 .and. &
1732 target_properties % properties_index(4, ip) == m)
then
1734 it1 = target_properties % properties_index(1, ip)
1735 it2 = target_properties % properties_index(2, ip)
1736 prop = target_properties % properties(ip)
1738 it1 = findloc(ions, it1, 1)
1739 it2 = findloc(ions, it2, 1)
1740 if (it1 > 0 .and. it2 > 0)
then
1741 crlv(it1, it2) = prop
1742 crlv(it2, it1) = prop
1748 call mpi_mod_file_write(fh, crlv, int(ntarg), int(ntarg))
1754 if (iand(input % opts(i) % vector_storage_method,
pass_to_cdenprop) /= 0 .and. &
1756 if (intf(i) % nchan > 0)
then
1757 lmax = max(int(lmax), maxval(intf(i) % lchl(1:intf(i) % nchan)))
1761 if (myrank == master)
then
1762 call generate_couplings(lmax, n_rg, rg, lm_rg)
1765 call mpi_mod_file_write(fh, n_rg)
1766 call mpi_mod_file_write(fh, rg, int(n_rg))
1767 call mpi_mod_file_write(fh, lm_rg, 6, int(n_rg))
1768 call mpi_mod_file_write(fh, nelc)
1769 call mpi_mod_file_write(fh, nz)
1770 call mpi_mod_file_write(fh, lrang2)
1771 call mpi_mod_file_write(fh, lamax)
1772 call mpi_mod_file_write(fh, ntarg)
1773 call mpi_mod_file_write(fh, inast)
1774 call mpi_mod_file_write(fh, nchmx)
1775 call mpi_mod_file_write(fh, nstmx)
1776 call mpi_mod_file_write(fh, lmaxp1)
1777 call mpi_mod_file_write(fh, rmatr)
1778 call mpi_mod_file_write(fh, bbloch)
1779 call mpi_mod_file_write(fh, etarg, int(ntarg))
1780 call mpi_mod_file_write(fh, ltarg, int(ntarg))
1781 call mpi_mod_file_write(fh, starg, int(ntarg))
1782 call mpi_mod_file_write(fh, nfdm)
1783 call mpi_mod_file_write(fh, delta_r)
1784 call mpi_mod_file_write(fh, r_points, int(nfdm + 1))
1788 if (iand(input % opts(i) % vector_storage_method,
pass_to_cdenprop) /= 0 .and. &
1791 if (myrank == master)
then
1792 lrgl = 1 + input % opts(i) % lambda
1793 nspn = int(2 * input % opts(i) % spin + 1, rmt_int)
1795 nchan = intf(i) % nchan
1796 mnp1 = solutions(i) % vec_dimen
1799 nconat(j) = count(intf(i) % ichl(1:nchan) == j)
1807 l2p(j) = intf(i) % lchl(j)
1808 m2p(j) = intf(i) % mchl(j)
1809 ichl(j) = intf(i) % ichl(j)
1813 call mpi_mod_file_write(fh, lrgl)
1814 call mpi_mod_file_write(fh, nspn)
1815 call mpi_mod_file_write(fh, npty)
1816 call mpi_mod_file_write(fh, nchan)
1817 call mpi_mod_file_write(fh, mnp1)
1818 call mpi_mod_file_write(fh, nconat, int(ntarg))
1819 call mpi_mod_file_write(fh, l2p, int(nchmx))
1820 call mpi_mod_file_write(fh, m2p, int(nchmx))
1822 if (myrank == master)
then
1824 eig(1:mnp1) = solutions(i) % ci_vec % ei(1:mnp1) + solutions(i) % core_energy
1827 call mpi_mod_file_write(fh, eig, int(nstmx))
1831 call wmat % redistribute(intf(i) % wamp(nfdm + 1), intf(i) % wamp(nfdm + 1) % blacs_context)
1832 wmat % CV = sqrt(2.0_wp) * wmat % CV
1833 call wmat % stream_write(fh)
1836 if (myrank == master)
then
1838 if (l <= intf(i) % ismax)
then
1843 ind = u * (u - 1) / 2 + v
1844 cf(j, k) = intf(i) % a(ind, l)
1849 call mpi_mod_file_write(fh, cf, int(nchmx), int(nchmx))
1852 call mpi_mod_file_write(fh, ichl, int(nchmx))
1854 s1 = intf(i) % wamp(1) % mat_dimen_r
1855 s2 = intf(i) % wamp(1) % mat_dimen_c
1857 call mpi_mod_file_write(fh, s1)
1858 call mpi_mod_file_write(fh, s2)
1862 call intf(i) % wamp(j) % stream_write(fh)
1868 call mpi_mod_file_close(fh, ierr)
1870 call master_timer % stop_timer(
"RMT interface")