162 use mpi_gbl,
only: mpi_xermsg
164 integer,
parameter :: mpiint = kind(mpi_comm_world)
165 integer,
parameter :: mpiofs = mpi_offset_kind
167 character(len=200) :: msg
169 integer(mpiint) :: ndims, gsizes(2), distrb(2), dargs(2), psizes(2), locsiz, fh, ierr, datype
170 integer(mpiint) :: comm_size, comm_rank, stat(MPI_STATUS_SIZE), mtwo = 2, dims(2)
171 integer(mpiofs) :: offs
174 class(mappedmatrix),
intent(inout) :: this
175 character(len=*),
intent(in) :: filename
176 integer(int32),
intent(in) :: u, rows, cols
177 integer(int64),
intent(in) :: offset
180 integer(int64) :: length
182 integer(blasint) :: zero = 0, one = 1, nprow, npcol, lrows, lcols, min_block_size, max_block_size, ld, info, myprow, mypcol
183 integer(blasint) :: brows, bcols
186 if (this % distributed)
then
187 call mpi_comm_size(mpi_comm_world, comm_size, ierr)
188 call assert_status(
'Failed to obtain world communicator size: ', int(ierr))
189 call mpi_comm_rank(mpi_comm_world, comm_rank, ierr)
190 call assert_status(
'Failed to obtain world communicator rank: ', int(ierr))
193 call mpi_dims_create(comm_size, mtwo, dims, ierr)
194 call assert_status(
'Failed to reshape world communicator to rectangular grid: ', int(ierr))
198 if (npcol * nprow /=
nprocs)
then
199 write (msg,
'(a,3(i0,a))')
'BLACS grid ', nprow,
'x', npcol,
' does not use all ',
nprocs,
' processes. Fix it.'
200 call mpi_xermsg(
'multidip_io',
'load_mapped_matrix', trim(msg), 1, 1);
203 call blacs_get(zero, zero, this % row_context)
204 call blacs_get(zero, zero, this % blk_context)
205 call blacs_gridinit(this % row_context,
'R', one, nprow * npcol)
206 call blacs_gridinit(this % blk_context,
'R', nprow, npcol)
207 call blacs_gridinfo(this % blk_context, nprow, npcol, myprow, mypcol)
212 this % block_size = min(rows / nprow, cols / npcol)
213 this % block_size = min(this % block_size, max_block_size)
214 this % block_size = max(this % block_size, min_block_size)
218 lrows = numroc(brows, this % block_size, myprow, zero, nprow)
219 lcols = numroc(bcols, this % block_size, mypcol, zero, npcol)
222 if (int(lrows, int64)*int(lcols, int64) > huge(1_int32))
then
223 print
'(a,i0,a,i0,a)',
'WARNING: Local portion of the dipole matrix has size ', lrows,
' x ', lcols,
'.'
224 print
'(9x,a)',
'This means that it cannot be indexed with 4-byte integers.'
225 print
'(9x,a,/)',
'If reading fails, try distributing the calculation more.'
228 call descinit(this % desc, brows, bcols, this % block_size, this % block_size, zero, zero, this % blk_context, ld, info)
230 allocate (this % mat(ld, lcols))
234 gsizes = [ rows, cols ]
235 distrb = [ mpi_distribute_cyclic, mpi_distribute_cyclic ]
236 dargs = [ this % block_size, this % block_size ]
237 psizes = [ nprow, npcol ]
238 locsiz = lrows * lcols
240 call mpi_file_open(mpi_comm_world, filename, mpi_mode_rdonly, mpi_info_null, fh, ierr)
241 call assert_status(
'Failed to open file for MPI-IO: ', int(ierr))
242 call mpi_type_create_darray(comm_size, comm_rank, ndims, gsizes, distrb, dargs, &
243 psizes, mpi_order_fortran, mpi_real8, datype, ierr)
244 call assert_status(
'Failed to define distributed array data type: ', int(ierr))
245 call mpi_type_commit(datype, ierr)
246 call assert_status(
'Failed to commit distributed array data type: ', int(ierr))
247 call mpi_file_set_view(fh, offs, mpi_real8, datype,
'native', mpi_info_null, ierr)
248 call assert_status(
'Failed to define file view: ', int(ierr))
249 call mpi_file_read_all(fh, this % mat, locsiz, mpi_real8, stat, ierr)
251 call mpi_type_free(datype, ierr)
252 call assert_status(
'Failed to release distributed array data type: ', int(ierr))
253 call mpi_file_close(fh, ierr)
258 length = int(rows, int64) * int(cols, int64) * wp_bytes
259 call this % mapping % init(filename, offset - 1, length)
260 call c_f_pointer(this % mapping % ptr, this % mat, [rows, cols])
262 allocate (this % mat(rows, cols))
355 use mpi_gbl,
only: mpi_xermsg
357 class(kmatrix),
intent(inout) :: km
359 integer :: k, n, ifail, key, nset, nrec, ninfo, ndata, ntarg, nvib, ndis, ie, gutot, ion
360 integer :: nopen, ndopen, nchsq, mye, nene, ierr
362 real(wp) :: dE1, dE2, r, rmass, en
363 real(wp),
allocatable :: kmat(:)
364 character(len=80) :: title, msg
366 print
'(/,A,I0,A,I0,/)',
'Reading K-matrices from unit ', km % lukmt,
', set ', km % nkset
368 call getset(km % lukmt, km % nkset, 11,
'UNFORMATTED', ifail)
370 read (km % lukmt) key, nset, nrec, ninfo, ndata
371 read (km % lukmt) title
372 read (km % lukmt) km % mgvn, km % stot, gutot, ion, r, rmass
373 read (km % lukmt) ntarg, nvib, ndis, km % nchan, km % maxne
375 print
'(2x,A,I0)',
'mgvn = ', km % mgvn
376 print
'(2x,A,I0)',
'stot = ', km % stot
377 print
'(2x,A,I0)',
'ntarg = ', ntarg
378 print
'(2x,A,I0)',
'nvib = ', nvib
379 print
'(2x,A,I0)',
'ndis = ', ndis
380 print
'(2x,A,I0)',
'nchan = ', km % nchan
381 print
'(2x,A,I0)',
'maxne = ', km % maxne
383 print
'(/,2x,A,/)',
'Energy ranges:'
386 do ie = 1, km % maxne
387 read (km % lukmt) k, n, de1, de2
388 print
'(4x,I4,I8,F8.3,F8.3)', k, n, de1, de2
389 km % nescat = km % nescat + n
393 allocate (km % escat(km % nescat), kmat(km % nchan * (km % nchan + 1)))
397 do ie = 1, km % nescat
398 read (km % lukmt, iostat = ierr) nopen, ndopen, nchsq, en
399 if (ierr == iostat_end)
then
400 print
'(/,2x,A,I0,A,I0,A)',
'WARNING: Unit ', km % lukmt,
' contains only ', ie - 1,
' K-matrices.'
401 print
'(11x,A)',
'This means that CFASYM failed during RSOLVE for some energies.'
402 print
'(11x,A)',
'The scattering energies MUST be consistent across symmetries!'
405 else if (ierr /= 0)
then
406 write (msg,
'(2x,a,i0,a)')
'ERROR ', ierr,
' while reading K-matrix file.'
407 call mpi_xermsg(
'multidip_io',
'read_kmatrix_file', trim(msg), 1, 1)
409 km % escat(ie) = en/2
410 if (iwarn .and. nopen < km % nchan)
then
411 print
'(/,2x,A,I0,A)',
'WARNING: Unit ', km % lukmt,
' contains only open-open subset of the full K-matrix.'
412 print
'(11x,A)',
'Use IKTYPE = 1 in RSOLVE to save full K-matrices.'
413 print
'(11x,A)',
'You may get spurious below-threshold noise.'
556 real(wp),
intent(out) :: bnd(:), Ei
557 integer,
intent(in) :: lubnd, mgvn0, stot0
559 real(wp),
allocatable :: xvec(:), etot(:), vtemp(:)
561 integer :: nbset, nchan, mgvn, stot, gutot, nstat, nbound, iprint, iwrite, ifail
562 character(len=11) :: bform
564 bform =
'unformatted'
569 open (lubnd, action =
'read', form = bform)
571 call readbh(lubnd, nbset, nchan, mgvn, stot, gutot, nstat, nbound, rr, bform, iprint, iwrite, ifail)
573 if (mgvn /= mgvn0 .or. stot /= stot0)
then
574 print
'(*(a,i0))',
'ERROR: Bound coefficients at unit ', lubnd,
' are for MGVN = ', mgvn,
', STOT = ', stot, &
575 ', but I am looking for MGVN = ', mgvn0,
', STOT = ', stot0
580 allocate (xvec(nbound*nchan), vtemp(nbound), etot(nbound))
582 call readbc(nstat, etot, vtemp, bnd, nbound, nchan, xvec)
732 type(moleculardata),
intent(inout) :: moldat
733 character(*),
intent(in) :: filename
734 logical,
intent(in) :: mpiio, read_wmat2
736 integer(int32),
allocatable :: nconat(:)
737 real(real64),
allocatable :: cf(:, :, :)
739 integer(int32) :: i, j, u, s, s1, s2, ntarg, nrg, lrang2, lamax, inast, nchmx, nstmx, lmaxp1, nfdm
740 integer(int32) :: lrgl, nspn, npty
741 integer(int64) :: offset, length
742 real(real64) :: bbloch, delta_r
744 open (newunit = u, file = filename, access =
'stream', status =
'old', action =
'read')
746 print
'(/,3A,/)',
'Reading file "', filename,
'"'
749 length = int(s1, int64) * int(s2, int64) * wp_bytes
750 allocate (moldat % iidipy(s), moldat % ifdipy(s), moldat % dipy(s))
751 read (u) moldat % iidipy, moldat % ifdipy
752 inquire (u, pos = offset)
754 moldat % dipy(i) % distributed = mpiio
755 call moldat % dipy(i) % load(filename, u, offset, s1, s2)
756 offset = offset + length
758 print
'(2x,A,*(1x,I0))',
'[m = -1] iidip =', moldat % iidipy
759 print
'(2x,A,*(1x,I0))',
' ifdip =', moldat % ifdipy
763 if (sum(abs(moldat % dipy(i) % mat)) == 0)
then
764 print
'(/,2x,A,/)',
'WARNING: Norm of some Y dipoles is zero. Something went wrong in CDENPROP?'
769 read (u, pos = offset) s, s1, s2
770 length = int(s1, int64) * int(s2, int64) * wp_bytes
771 allocate (moldat % iidipz(s), moldat % ifdipz(s), moldat % dipz(s))
772 read (u) moldat % iidipz, moldat % ifdipz
773 inquire (u, pos = offset)
775 moldat % dipz(i) % distributed = mpiio
776 call moldat % dipz(i) % load(filename, u, offset, s1, s2)
777 offset = offset + length
779 print
'(2x,A,*(1x,I0))',
'[m = 0] iidip =', moldat % iidipz
780 print
'(2x,A,*(1x,I0))',
' ifdip =', moldat % ifdipz
784 if (sum(abs(moldat % dipz(i) % mat)) == 0)
then
785 print
'(/,2x,A,/)',
'WARNING: Norm of some Z dipoles is zero. Something went wrong in CDENPROP?'
790 read (u, pos = offset) s, s1, s2
791 length = int(s1, int64) * int(s2, int64) * wp_bytes
792 allocate (moldat % iidipx(s), moldat % ifdipx(s), moldat % dipx(s))
793 read (u) moldat % iidipx, moldat % ifdipx
794 inquire (u, pos = offset)
796 moldat % dipx(i) % distributed = mpiio
797 call moldat % dipx(i) % load(filename, u, offset, s1, s2)
798 offset = offset + length
800 print
'(2x,A,*(1x,I0))',
'[m = +1] iidip =', moldat % iidipx
801 print
'(2x,A,*(1x,I0))',
' ifdip =', moldat % ifdipx
805 if (sum(abs(moldat % dipx(i) % mat)) == 0)
then
806 print
'(/,2x,A,/)',
'WARNING: Norm of some X dipoles is zero. Something went wrong in CDENPROP?'
811 read (u, pos = offset) ntarg
812 print
'(/,2x,A,I0)',
'ntarg = ', ntarg
813 allocate (moldat % crlv(ntarg, ntarg, 3))
814 read (u) moldat % crlv
817 allocate (moldat % rg(nrg), moldat % lm_rg(6, nrg))
818 read (u) moldat % rg, moldat % lm_rg
820 read (u) moldat % nelc, moldat % nz, lrang2, lamax, ntarg, inast, nchmx, nstmx, lmaxp1
821 read (u) moldat % rmatr, bbloch
822 allocate (moldat % etarg(ntarg), moldat % ltarg(ntarg), moldat % starg(ntarg))
823 read (u) moldat % etarg, moldat % ltarg, moldat % starg
824 read (u) nfdm, delta_r
825 allocate (moldat % r_points(nfdm + 1))
826 read (u) moldat % r_points
827 print
'(2x,A,*(1x,F8.3))',
'sampling radii:', moldat % r_points
829 print
'(/,2x,A)',
'number of inner eigenstates per symmetry'
831 allocate (nconat(ntarg), moldat % l2p(nchmx, inast), moldat % m2p(nchmx, inast), moldat % eig(nstmx, inast), &
832 moldat % wamp(inast), cf(nchmx, nchmx, lamax), moldat % ichl(nchmx, inast), &
833 moldat % mgvns(inast), moldat % stot(inast), moldat % nchan(inast), moldat % mnp1(inast), &
834 moldat % wmat2(nfdm, inast))
836 inquire (u, pos = offset)
838 length = int(nchmx, int64) * int(nstmx, int64) * wp_bytes
842 read (u, pos = offset) lrgl, nspn, npty, moldat % nchan(i), moldat % mnp1(i)
843 moldat % mgvns(i) = lrgl - 1
844 moldat % stot(i) = nspn
845 print
'(4x,I3,I8)', moldat % mgvns(i), moldat % mnp1(i)
846 read (u) nconat, moldat % l2p(:, i), moldat % m2p(:, i)
847 read (u) moldat % eig(:, i)
848 inquire (u, pos = offset)
849 call moldat % wamp(i) % load(filename, u, offset, nchmx, nstmx)
850 offset = offset + length
851 read (u, pos = offset) cf, moldat % ichl(:, i)
853 inquire (u, pos = offset)
858 call moldat % wmat2(j, i) % load(filename, u, offset, s1, s2)
859 offset = offset + int(s1, int64) * int(s2, int64) * wp_bytes
862 offset = offset + int(s1, int64) * int(s2, int64) * nfdm * wp_bytes
868 print
'(/,2x,A,I0,A,I0,A)',
'channels in symmetry #', i,
' (IRR ', moldat % mgvns(i),
'):'
869 do j = 1, moldat % nchan(i)
870 print
'(2x,I4,A,I6,I3,SP,I6)', j,
':', moldat % ichl(j, i), moldat % l2p(j, i), moldat % m2p(j, i)
871 if (moldat % ichl(j, i) > ntarg)
then
872 print
'(4(A,I0),A)',
'Warning: Channel ', j,
' in symmetry ', moldat % mgvns(i),
' is coupled to state ', &
873 moldat % ichl(j, i),
', which is beyond the number of targets ', ntarg,
' (bug in mpi-scatci!)'
874 moldat % ichl(j, i) = ntarg
894 integer,
intent(in) :: lutarg
895 real(wp),
allocatable,
intent(inout) :: etarg(:), prop(:,:,:)
897 integer :: i, key, set, nrec, nnuc, ntarg, nmom, itarg, jtarg, imgvn, jmgvn, l, m, isw
898 real(wp) :: x, rmoi(3), dum(7)
901 print
'(/,A)',
'Reading target transition dipoles'
903 inquire(lutarg, opened = is_open)
904 if (.not. is_open)
then
905 open (lutarg, action =
'read')
907 call readmh(lutarg, key, set, nrec, nnuc, ntarg, nmom, isw, rmoi)
909 print
'(/,A,I0,A)',
'ERROR: Key ', key,
' is not DENPROP property file, aborting.'
912 print
'(/,1x,A,I0)',
'Number of records: ', nrec
913 print
'(1x,A,I0)',
'Number of nuclei: ', nnuc
914 print
'(1x,A,I0)',
'Number of targets: ', ntarg
915 print
'(1x,A,I0)',
'Number of properties: ', nmom
919 print
'(/,A,I0,A)',
'ERROR: Key ', key,
' is not nuclear definition, aborting.'
923 allocate (etarg(ntarg))
925 read (lutarg, *) key, dum, etarg(i)
927 print
'(/,A,I0,A)',
'ERROR: Key ', key,
' is not target definition, aborting.'
931 allocate (prop(ntarg, ntarg, 3))
934 read (lutarg, *) key, itarg, imgvn, jtarg, jmgvn, nnuc, l, m, x
936 print
'(/,A,I0,A)',
'ERROR: Key ', key,
' is not property definition, aborting.'
940 prop(itarg, jtarg, m + 2) = x
941 prop(jtarg, itarg, m + 2) = x
944 if (.not. is_open)
then
1056 integer(blasint),
parameter :: one = 1, zero = 0
1058 type(moleculardata),
intent(in) :: moldat
1059 integer,
intent(in) :: component, irrpair, nf, nn
1060 character(len=1),
intent(in) :: transp
1061 real(wp),
intent(inout) :: X(:, :, :), Y(:, :, :)
1063 integer(blasint) :: lda, ldb, ldc, m, n, k, info, Xdesc(9), Xdesc2D(9), Ydesc(9), Ydesc2D(9), desc(9), gn
1064 integer(blasint) :: Xlocr, Xlocc, Ylocr, Ylocc, ldX, ldY, rctx, bctx, rbksz, cbksz, myprow, mypcol, nprow, npcol
1067 real(wp),
allocatable :: Xloc(:, :), Yloc(:, :)
1068 real(wp),
pointer :: dips(:, :)
1074 n =
size(x, 2) *
size(x, 3)
1078 select case (component)
1080 dist = moldat % dipx(irrpair) % distributed
1081 desc = moldat % dipx(irrpair) % desc
1082 rctx = moldat % dipx(irrpair) % row_context
1083 bctx = moldat % dipx(irrpair) % blk_context
1084 lda =
size(moldat % dipx(irrpair) % mat, 1)
1085 dips => moldat % dipx(irrpair) % mat(:, :)
1087 dist = moldat % dipy(irrpair) % distributed
1088 desc = moldat % dipy(irrpair) % desc
1089 rctx = moldat % dipy(irrpair) % row_context
1090 bctx = moldat % dipy(irrpair) % blk_context
1091 lda =
size(moldat % dipy(irrpair) % mat, 1)
1092 dips => moldat % dipy(irrpair) % mat(:, :)
1094 dist = moldat % dipz(irrpair) % distributed
1095 desc = moldat % dipz(irrpair) % desc
1096 rctx = moldat % dipz(irrpair) % row_context
1097 bctx = moldat % dipz(irrpair) % blk_context
1098 lda =
size(moldat % dipz(irrpair) % mat, 1)
1099 dips => moldat % dipz(irrpair) % mat(:, :)
1102#ifdef WITH_SCALAPACK
1108 call blacs_gridinfo(bctx, nprow, npcol, myprow, mypcol)
1111 call descinit(xdesc, k, gn, ldb, n, zero, zero, rctx, ldb, info)
1112 call assert_status(
'Failed to set up X BLACS descriptor: ', int(info))
1113 call descinit(ydesc, m, gn, ldc, n, zero, zero, rctx, ldc, info)
1114 call assert_status(
'Failed to set up Y BLACS descriptor: ', int(info))
1117 rbksz =
clip(min(nf, nn) / int(nprow), 1, 64)
1118 cbksz =
clip(int(gn / npcol), 1, 64)
1121 xlocr = numroc(k, rbksz, myprow, zero, nprow); ldx = max(one, xlocr)
1122 xlocc = numroc(gn, cbksz, mypcol, zero, npcol)
1125 ylocr = numroc(m, rbksz, myprow, zero, nprow); ldy = max(one, ylocr)
1126 ylocc = numroc(gn, cbksz, mypcol, zero, npcol)
1129 allocate (xloc(ldx, xlocc), yloc(ldy, ylocc))
1132 call descinit(xdesc2d, k, gn, rbksz, cbksz, zero, zero, bctx, ldx, info)
1133 call assert_status(
'Failed to set up X2D BLACS descriptor: ', int(info))
1134 call descinit(ydesc2d, m, gn, rbksz, cbksz, zero, zero, bctx, ldy, info)
1135 call assert_status(
'Failed to set up Y2D BLACS descriptor: ', int(info))
1138 call pdgemr2d(k, gn, x, one, one, xdesc, xloc, one, one, xdesc2d, bctx)
1139 call pdgemm(transp,
'N', m, gn, k,
rone, dips, one, one, desc, xloc, one, one, xdesc2d,
rzero, yloc, one, one, ydesc2d)
1140 call pdgemr2d(m, gn, yloc, one, one, ydesc2d, y, one, one, ydesc, bctx)
1143 call blas_dgemm(transp,
'N', m, n, k,
rone, dips, lda, x, ldb,
rzero, y, ldc)
1144#ifdef WITH_SCALAPACK
1197 type(moleculardata),
intent(in) :: moldat
1198 integer,
intent(in) :: irr
1199 character(len=1),
intent(in) :: transp
1200 real(wp),
intent(inout) :: X(:,:), Y(:,:)
1202 integer(blasint) :: m, n, k, lda, ldb, ldc
1203 real(wp) :: alpha = 1, beta = 0
1204 real(wp),
pointer :: wamp(:, :)
1206 if (transp ==
'T')
then
1207 m = moldat % mnp1(irr)
1208 n = int(
size(x, 2), blasint)
1209 k = moldat % nchan(irr)
1211 m = moldat % nchan(irr)
1212 n = int(
size(x, 2), blasint)
1213 k = moldat % mnp1(irr)
1216 lda =
size(moldat % wamp(irr) % mat, 1)
1220 if (lda < merge(m, k, transp ==
'N') .or. ldb < k .or. ldc < m)
then
1221 print
'(a)',
'ERROR: Incompatible matrix dimensions in apply_boundary_amplitudes'
1222 print
'(7x,a,6(", ",a,1x,i0))', transp,
'm =', m,
'n =', n,
'k =', k,
'lda =', lda,
'ldb =', ldb,
'ldc =', ldc
1226 wamp => moldat % wamp(irr) % mat(:, :)
1228 call blas_dgemm(transp,
'N', m, n, k, alpha, wamp, lda, x, ldb, beta, y, ldc)
1292 use mpi_gbl,
only: mpi_reduce_inplace_sum_wp
1294 type(moleculardata),
intent(in) :: moldat
1295 character(len=*),
intent(in) :: suffix
1296 integer,
intent(in) :: nesc
1297 complex(wp),
allocatable,
intent(in) :: M(:, :, :)
1299 complex(wp),
allocatable :: val(:)
1300 real(wp),
allocatable :: reval(:), imval(:)
1302 integer :: ie, irr, mgvn, u, ichan, ichlf, lf, mf, mye
1303 character(len=100) :: filename
1305 allocate (val(nesc))
1308 do irr = 1,
size(moldat % mgvns)
1309 mgvn = moldat % mgvns(irr)
1310 do ichan = 1,
size(m, 1)
1315 val(ie) = m(ichan, mye, mgvn)
1321 call mpi_reduce_inplace_sum_wp(reval, nesc)
1322 call mpi_reduce_inplace_sum_wp(imval, nesc)
1323 val = cmplx(reval, imval, wp)
1326 if (
myproc == 1 .and. any(val /= 0))
then
1327 ichlf = moldat % ichl(ichan, irr)
1328 lf = moldat % l2p(ichan, irr)
1329 mf = moldat % m2p(ichan, irr)
1330 write (filename,
'(3(A,I0),A,SP,I0,3A)')
'pwdip-', mgvn,
'-(', ichlf,
',', lf,
',', mf,
')', suffix,
'.txt'
1331 open (newunit = u, file = filename, action =
'write', form =
'formatted')
1332 write (u,
'(2E25.15)') val
1349 use mpi_gbl,
only: mpi_reduce_inplace_sum_wp
1351 character(len=*),
intent(in) :: stem
1352 integer,
allocatable,
intent(in) :: chains(:, :)
1353 complex(wp),
allocatable,
intent(in) :: M(:, :, :, :)
1354 integer,
intent(in) :: nesc
1356 character(len=100) :: filename, history
1357 character(len=1),
parameter :: xyz(-1:1) = [
'y',
'z',
'x' ]
1358 character(len=1),
parameter :: sph(-1:1) = [
'm',
'0',
'p' ]
1360 complex(wp),
allocatable :: val(:)
1361 real(wp),
allocatable :: reval(:), imval(:)
1363 integer :: u, itarg, ntarg, ichain, nchain, ipw, npw, icomp, lf, mf, ie, mye
1369 allocate (val(nesc))
1373 do ichain = 1, nchain
1380 val(ie) = m(mye, ipw, ichain, itarg)
1386 call mpi_reduce_inplace_sum_wp(reval, nesc)
1387 call mpi_reduce_inplace_sum_wp(imval, nesc)
1388 val = cmplx(reval, imval, wp)
1391 if (
myproc == 1 .and. any(val /= 0))
then
1392 lf = int(sqrt(real(ipw - 1, wp)))
1393 mf = ipw - lf*lf - lf - 1
1395 do icomp = 1,
size(chains, 1)
1396 select case (trim(stem))
1397 case (
'xyz'); history = xyz(chains(icomp, ichain)) // trim(history)
1398 case (
'sph'); history = sph(chains(icomp, ichain)) // trim(history)
1401 write (filename,
'(3A,I0,A,I0,A,SP,I0,A)')
'rawdip-', trim(history),
'-(', itarg,
',', lf,
',', mf,
').txt'
1402 open (newunit = u, file = filename, action =
'write', form =
'formatted')
1403 write (u,
'(2E25.15)') val
1422 use photo_outerio,
only: write_pw_dipoles
1423 use mpi_gbl,
only: mpi_reduce_inplace_sum_wp
1426 type(moleculardata),
intent(in) :: moldat
1427 integer,
allocatable,
intent(in) :: chains(:, :)
1428 complex(wp),
allocatable,
intent(in) :: M(:, :, :, :)
1429 real(wp),
intent(in) :: escat(:)
1430 integer,
intent(in) :: lu_pw_dipoles
1432 complex(wp),
allocatable :: val(:)
1433 real(wp),
allocatable :: reval(:), imval(:), re_pw_dipoles(:,:,:,:), im_pw_dipoles(:,:,:,:)
1435 integer :: itarg, ntarg, ichain, nchain, ipw, npw, icomp, lf, mf, ie, mye, irr, mgvn, stot, gutot, nch, ch
1437 character(len=11) :: form_pw_dipoles
1438 character(len=80) :: title
1440 integer :: lmax_property, dip_comp_present(3), lu_pw_dipoles_m, nset_pw_dipoles, nesc, iprnt, iwrite, ifail
1441 integer,
allocatable :: ichl(:), lvchl(:), mvchl(:), starg(:), mtarg(:), gtarg(:)
1442 real(wp),
allocatable :: evchl(:)
1443 real(wp) :: bound_state_energies(1), target_energy
1449 ntarg =
size(moldat % etarg)
1451 allocate (val(nesc), starg(ntarg), mtarg(ntarg), gtarg(ntarg))
1454 title =
'MULTIDIP 1-PHOTON DIPOLES'
1455 starg = moldat % starg
1456 mtarg(:) = moldat % ltarg(:) - 1
1458 target_energy = minval(moldat % etarg)
1459 bound_state_energies = moldat % eig(1,1)
1461 form_pw_dipoles =
'FORMATTED'
1462 iwrite = output_unit
1467 do irr = 1,
size(moldat % mgvns)
1469 mgvn = moldat % mgvns(irr)
1470 stot = moldat % stot(irr)
1472 nch = moldat % nchan(irr)
1474 allocate(re_pw_dipoles(1,nch,3,nesc))
1475 allocate(im_pw_dipoles(1,nch,3,nesc))
1477 re_pw_dipoles = 0.0_wp
1478 im_pw_dipoles = 0.0_wp
1480 dip_comp_present = 0
1483 do ichain = 1, nchain
1486 itarg = moldat % ichl(ch,irr)
1487 lf = moldat % l2p(ch,irr)
1488 mf = moldat % m2p(ch,irr)
1490 ipw = lf * lf + lf + mf + 1
1496 val(ie) = m(mye, ipw, ichain, itarg)
1502 call mpi_reduce_inplace_sum_wp(reval, nesc)
1503 call mpi_reduce_inplace_sum_wp(imval, nesc)
1504 val = cmplx(reval, imval, wp)
1509 if (any(abs(val(:)) > 0.0_wp)) dip_comp_present(
carti(ichain)) = 1
1513 re_pw_dipoles(1,ch,
carti(ichain),ie) = real(val(ie),wp)
1514 im_pw_dipoles(1,ch,
carti(ichain),ie) = -aimag(val(ie))
1522 lu_pw_dipoles_m = lu_pw_dipoles + mgvn
1524 allocate(ichl(nch), lvchl(nch), mvchl(nch), evchl(nch))
1526 ichl(1:nch) = moldat % ichl(1:nch,irr)
1527 lvchl(1:nch) = moldat % l2p (1:nch,irr)
1528 mvchl(1:nch) = moldat % m2p (1:nch,irr)
1532 evchl(ch) = 2 * ( moldat % etarg(ichl(ch)) - moldat % etarg(1) )
1535 call write_pw_dipoles( lu_pw_dipoles_m, nset_pw_dipoles, form_pw_dipoles, title, mgvn, &
1536 stot, gutot, starg, mtarg, gtarg, ichl, lvchl, mvchl, evchl, escat, lmax_property,&
1537 dip_comp_present, bound_state_energies, target_energy, &
1538 re_pw_dipoles, im_pw_dipoles, iprnt, iwrite, ifail )
1540 deallocate(re_pw_dipoles, im_pw_dipoles, ichl, lvchl, mvchl, evchl)