utils_wrt.F90 22.4 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
!!-------------------------------------------------------
!!---- Relaxed Selected Excitation (RelaxSE)
!!-------------------------------------------------------
!!---- This file is part of RelaxSE
!!---- 
!!---- The RelaxSE project is distributed under LGPL. In agreement with the
!!---- Intergovernmental Convention of the ILL, this software cannot be used
!!---- in military applications.
!!---- 
!!---- Copyright (C) 2016-2021  Institut Laue-Langevin (ILL), Grenoble, FRANCE
!!----                          Institut Neel - CNRS-UPR2940 (CNRS), Grenoble, FRANCE
!!---- 
!!---- Authors: Elisa REBOLINI (ILL)             rebolini@ill.fr
!!----          Marie-Bernadette LEPETIT (CNRS)  Marie-Bernadette.Lepetit@neel.cnrs.fr
!!---- 
!!---- RelaxSE is free software; you can redistribute it and/or
!!---- modify it under the terms of the GNU Lesser General Public
!!---- License as published by the Free Software Foundation; either
!!---- version 3.0 of the License, or (at your option) any later version.
!!---- 
!!---- RelaxSE is distributed in the hope that it will be useful,
!!---- but WITHOUT ANY WARRANTY; without even the implied warranty of
!!---- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
!!---- Lesser General Public License for more details.
!!---- 
!!---- You should have received a copy of the GNU Lesser General Public
!!---- License along with this library; if not, see <http://www.gnu.org/licenses/>.
!!---- 

!$============================================================
!> @brief Utilitaires pour le traitement des I/O
!! Wrtdet : écrit un det
!! Wrtact : écrit la partie active d'un det
!! Wrtactalpha  : Ecriture partie active alpha des det
!! Wrtmat : Ecriture matrice réelle 
!$============================================================

module utils_wrt

  use typedet
  use info
  
  implicit none
  private
  
  public :: &
       wrt_deter_block, &
       wrtdet, &
       wrtact, &
       wrtactalpha, &
51
52
       wrtmat, wrtmat_accurate, wrtmatE, wrt_bdet, wrt_info, &
       wrt_WF
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
  
  ! interface  wrt_bdet
  !    module procedure wrt_bdet
  ! end interface wrt_bdet
  
  interface wrtdet
     module procedure wrtdet_global, wrtdet_local
  end interface wrtdet

  interface wrt_deter_block
     module procedure wrt_deter_dblock
  end interface wrt_deter_block
     
contains
  
!!$  !$==================================================================== 
!!$  !> @brief Print a deter_block object
!!$  !> @author Elisa Rebolini
!!$  !> @date Nov 2017
!!$  !$==================================================================== 
!!$  subroutine wrt_deter_tblock(d, iout, o_info)
!!$
!!$    implicit none
!!$
!!$    type(deter_tblock), intent(in) :: d
!!$    integer, intent(in)           :: iout
!!$    type(o_infotype), optional, intent(in) :: o_info
!!$    
!!$    integer :: i
!!$    
!!$    write(iout,'(A,I0)') 'Determinant block T', d%name
!!$    !write(iout,'(X,I0,X,A)') d%nelCAS,'extra active electrons'
!!$    write(iout,*) 'Act   Occ   Ligo  Ligv  Virt'
!!$    write(iout,'(X,(I2,4X),4(I1,5X))') d%nelCAS, d%nexcOcc, d%nexcLigo, &
!!$         d%nexcLigv, d%nexcVirt
!!$    write(iout,'(A,I0,A)') 'contains ',d%ndet,' determinants'
!!$    write(iout,*) ''
!!$    if (associated(d%elms)) then
!!$       if ((present(o_info)) .and. (d%ndet .ne. 0)) then
!!$          do i = 1, d%ndet
!!$             call wrtdet(d%elms(i), iout, o_info)
!!$          enddo
!!$       endif
!!$    endif
!!$        
!!$  end subroutine wrt_deter_tblock

  !$==================================================================== 
  !> @brief Print a deter_block object
  !> @author Elisa Rebolini
  !> @date Nov 2017
  !$==================================================================== 
  subroutine wrt_deter_dblock(d, iout, o_info)

    implicit none

    type(deter_dblock), intent(in) :: d
    integer, intent(in)           :: iout
    type(o_infotype), optional, intent(in) :: o_info
    
    integer :: i
    
    write(iout,'(A,I0)') 'Determinant block D', d%name
    !write(iout,'(X,I0,X,A)') d%nelCAS,'extra active electrons'
    write(iout,*) 'Act   Occ   Virt'
    write(iout,'(X,(I2,4X),2(I1,5X))') d%nelCAS, d%nexcOcc, d%nexcVirt
    write(iout,'(A,I0,A)') 'contains ',d%ndet,' determinants'
    write(iout,*) ''
    if (associated(d%elms)) then
       if ((present(o_info)) .and. (d%ndet .ne. 0)) then
          do i = 1, d%ndet
             call wrtdet(d%elms(i), iout, o_info)
          enddo
       endif
    endif
        
  end subroutine wrt_deter_dblock
  !$============================================================
  !> @brief Write all determinants in binary file 
  !> @author MBL
  !> @date avril 2020
  !> @param
  !> @param
  !$============================================================
  subroutine wrt_bdet(det,ndet,iunit)
    ! -------- Donnes locales -----------------------------------
    Implicit none
    integer, intent(in) :: ndet
    Type(deter), dimension(ndet), intent(in)     :: det
    integer, intent(in)         :: iunit
    integer :: idet
    
    do idet = 1,ndet
       write(iunit) det(idet)%detact, det(idet)%dettr,  det(idet)%detprt
    end do
    
  end subroutine wrt_bdet
  !$============================================================
  !> @brief Write x_info types in binary file 
  !> @author MBL
  !> @date avril 2020
  !> @param
  !> @param
  !$============================================================
157
  subroutine wrt_info(prog_info,g_info,o_info,v_info,det_info,d,sym_info,iunit)
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
    ! -------- Donnes locales -----------------------------------
    Implicit none
    type(prog_infotype), intent(in) :: prog_info
    type(g_infotype),    intent(in) :: g_info
    type(o_infotype),    intent(in) :: o_info
    type(v_infotype),    intent(in) :: v_info
    type(det_infotype),  intent(in) :: det_info
    type(deter_dblocklist),intent(in):: d
    type(sym_infotype),  intent(in) :: sym_info
    integer,             intent(in) :: iunit

    integer :: nblock, i 
    Integer, dimension(:), allocatable :: shtblkdet, nblkdet, deter_index

    nblock = d%nblock
    allocate(shtblkdet(nblock), nblkdet(nblock), deter_index(nblock))
    do i=1,nblock
       shtblkdet(i)   = d%detblock(i)%p%shift
       nblkdet(i)     = d%detblock(i)%p%ndet
       deter_index(i) = d%deter_index(i)
    end do

    write(iunit) prog_info
    write(iunit) g_info
    write(iunit) o_info
    write(iunit) v_info
    write(iunit) det_info
    write(iunit) nblock
    write(iunit) shtblkdet(1:nblock), nblkdet(1:nblock), deter_index(1:nblock) 
    write(iunit) sym_info
    
  end subroutine wrt_info
  !$============================================================
  !> @brief Write a determinant using the global variables
  !> @author
  !> @date
  !> @param
  !> @param
  !$============================================================
  subroutine wrtdet_global(d, iunit, o_info)  
        
    ! -------- Donnes locales -----------------------------------
    Implicit none
    Type(deter), intent(in)     :: d
    integer, intent(in)         :: iunit
    type(o_infotype), intent(in):: o_info

    call wrtdet_local(d, iunit, o_info%ngel, o_info%nocc, &
         o_info%nligo, o_info%nact, o_info%nligv, &
         o_info%nvirt, o_info%ndel)
    
  end subroutine wrtdet_global

  !$============================================================
  !> @brief Write a determinant without using the global variables
  !> @author
  !> @date
  !> @param
  !> @param
  !$============================================================
  subroutine wrtdet_local(d, iunit, lngel, lnocc, lnligo, lnact, &
       lnligv, lnvirt, lndel)

    ! -------- Donnes locales -----------------------------------
    implicit none
    type(deter), intent(in) :: d
    integer, intent(in) :: iunit
    integer, intent(in) :: lngel, lnocc, lnligo, lnact, lnligv, &
         lnvirt, lndel   
    
    integer :: ibit, it1,it2,ip1,ip2, ishpa, ishpb, ishta, ishtb
    Character*1 :: spt1, spt2, spp1, spp2
    ! -------- Code ---------------------------------------------

    do ibit = 0,lnact-1
       write(iunit,'(i1)',advance='no') ibits(d%detact, ibit, 1)
    end do
    write(iunit,'(" ")',advance='no')
    do ibit = lnact, 2*lnact-1
       write(iunit,'(i1)',advance='no') ibits(d%detact, ibit, 1)
    end do
    write(iunit,'(" ")',advance='no')

    ! trous et particules
    ishta = 2*lngel
    ishtb = 2*lngel + lnocc + lnligo
    ishpa = 2*lngel + 2*lnocc + 2*lnligo + 2*lnact 
    ishpb = 2*lngel + 2*lnocc + 2*lnligo + 2*lnact + lnligv + lnvirt

    if (d%dettr(1).le.ishtb) then  
       it1  = d%dettr(1) - lngel
       spt1 = 'u'
    else 
       it1  = d%dettr(1) - lngel - lnocc - lnligo
       spt1 = 'd'
    end if
    if (d%dettr(2).le.ishtb) then
       it2  = d%dettr(2) - lngel
       spt2 = 'u'
    else 
       it2  = d%dettr(2) - lngel - lnocc - lnligo
       spt2 = 'd'
    end if

    if (d%detprt(1).le.ishpb) then
       ip1  = d%detprt(1) - lngel - lnocc - lnligo - lnact
       spp1 = 'u'
    else 
       ip1  = d%detprt(1) - lngel - lnocc - lnligo - lnact - lnligv - lnvirt
       spp1 = 'd'
    end if
    if (d%detprt(2).le.ishpb) then
       ip2  = d%detprt(2) - lngel  - lnocc - lnligo - lnact
       spp2 = 'u'
    else 
       ip2  = d%detprt(2) - lngel - lnocc - lnligo - lnact - lnligv - lnvirt
       spp2 = 'd'
    end if

    if (d%dettr(1).eq.0 .and. d%dettr(2).ne.0) then 
       write(iunit,9022) d%dettr,d%detprt   
       call SASS_quit(">>> Erreur det <<<",f_output)
    else if (d%detprt(1).eq.0 .and. d%detprt(2).ne.0) then 
       write(iunit,9022) d%dettr,d%detprt   
       call SASS_quit(">>> Erreur det <<<",f_output)
    else if (d%dettr(1).eq.0 .and. d%dettr(2).eq.0) then 
       if (d%detprt(1).eq.0 .and. d%detprt(2).eq.0) then
          write(iunit,*)
          return
       else if (d%detprt(1).ne.0 .and. d%detprt(2).eq.0) then
          write(iunit,9001) ip1,spp1
          return
       else if (d%detprt(1).ne.0 .and. d%detprt(2).ne.0) then
          write(iunit,9002) ip1,spp1, ip2,spp2
          return
       end if
    else if (d%dettr(1).ne.0 .and. d%dettr(2).eq.0) then 
       if (d%detprt(1).eq.0 .and. d%detprt(2).eq.0) then
          write(iunit,9010) it1,spt1  
          return
       else if (d%detprt(1).ne.0 .and. d%detprt(2).eq.0) then
          write(iunit,9011)  it1,spt1, ip1,spp1    
          return
       else if (d%detprt(1).ne.0 .and. d%detprt(2).ne.0) then
          write(iunit,9012)  it1,spt1, ip1,spp1, ip2,spp2
          return
       end if
    else if (d%dettr(1).ne.0 .and. d%dettr(2).ne.0) then 
       if (d%detprt(1).eq.0 .and. d%detprt(2).eq.0) then
          write(iunit,9020)  it2,spt2, it1,spt1
          return
       else if (d%detprt(1).ne.0 .and. d%detprt(2).eq.0) then
          write(iunit,9021)  it2,spt2, it1,spt1, ip1,spp1
          return
       else if (d%detprt(1).ne.0 .and. d%detprt(2).ne.0) then
          write(iunit,9022) it2,spt2, it1,spt1, ip1,spp1,  ip2,spp2
          return
       end if
    end if
317
    
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454

9001 format(17x,"  ->  ",I5,a1)
9002 format(17x,"  ->  ",I5,a1," , ",i5,a1)
9010 format(11x,i5,a1,"  ->  ")
9011 format(11x,i5,a1,"  ->  ",I5,a1)
9012 format(11x,i5,a1,"  ->  ",I5,a1," , ",i5,a1)
9020 format(2x,i5,a1," , ",i5,a1,"  ->  ")
9021 format(2x,i5,a1," , ",i5,a1,"  ->  ",I5,a1)
9022 format(2x,I5,a1," , ",i5,a1,"  ->  ",I5,a1," , ",i5,a1)
  end subroutine wrtdet_local

  
!!$============================================================
  Subroutine wrtact(dact, iunit, yno, nact)  
    !------------------------------------------------------------
    ! Ecriture partie active des det
    ! -------- Donnes locales -----------------------------------
    Implicit none
    Integer(Kind= kindact), intent(in) :: dact
    integer, intent(in)                :: iunit, nact
    logical, intent(in)                :: yno
    
    integer ::  ibit
        
    ! -------- Code ---------------------------------------------
    do ibit = 0,NACT-1
       write(iunit,'(i1)',advance='no') ibits(dact, ibit, 1)
    end do
    write(iunit,'(" ")',advance='no')
    do ibit = nact, 2*nact-1
       write(iunit,'(i1)',advance='no') ibits(dact, ibit, 1)
    end do
    if (.not.yno) write(iunit,*)
  end Subroutine wrtact
  
!!$============================================================
  Subroutine wrtactalpha(dact, iunit, yno, nact)  
    !------------------------------------------------------------
    ! Ecriture partie active alpha des det
    ! -------- Donnes locales -----------------------------------
    Implicit none
    Integer(Kind= kindact), intent(in) :: dact
    integer, intent(in)                :: iunit, nact
    logical, intent(in)                :: yno
    
    integer :: ibit
    
    ! -------- Code ---------------------------------------------
    do ibit = 0,nact-1
       write(iunit,'(i1)',advance='no') ibits(dact, ibit, 1)
    end do
    if (.not.yno) write(iunit,*)
  end Subroutine wrtactalpha
       
!!$============================================================
  Subroutine wrtmat(mat, dimmaxi, dimi, dimj, iunit)  
    !------------------------------------------------------------
    ! Ecriture matrice réelle 
    ! -------- Donnes locales -----------------------------------

    Implicit none
    Integer (KIND=kd_int), intent(in) :: dimmaxi, dimi, dimj, iunit
    Real (KIND=kd_dble), dimension(dimmaxi,dimj), intent(in) :: mat
    Integer (KIND=kd_int) :: i,j,npas, kpas
    ! -------- Code ---------------------------------------------
    npas = dimj/10
    if (npas.eq.0) goto 10
    do kpas = 1,npas
       do i = 1, dimi
          write(iunit,9993)   (mat(i,j), j=(kpas-1)*10+1,kpas*10)
       end do
       write(iunit,*)
    end do
    
10  if (mod(dimj,10).eq.0) return 
    do i = 1, dimi
       write(iunit,9993)   (mat(i,j), j=npas*10+1,dimj)
    end do
    
9993 format (5x,10(F12.6,1x))        
  end Subroutine wrtmat


  !$============================================================
  Subroutine wrtmat_accurate(mat, dimmaxi, dimi, dimj, iunit)  
    !------------------------------------------------------------
    ! Ecriture matrice réelle 
    ! -------- Donnes locales -----------------------------------

    Implicit none
    Integer (KIND=kd_int), intent(in) :: dimmaxi, dimi, dimj, iunit
    Real (KIND=kd_dble), dimension(dimmaxi,dimj), intent(in) :: mat
    Integer (KIND=kd_int) :: i,j,npas, kpas
    ! -------- Code ---------------------------------------------
    npas = dimj/10
    if (npas.eq.0) goto 10
    do kpas = 1,npas
       do i = 1, dimi
          write(iunit,9993)   (mat(i,j), j=(kpas-1)*10+1,kpas*10)
       end do
       write(iunit,*)
    end do
    
10  if (mod(dimj,10).eq.0) return 
    do i = 1, dimi
       write(iunit,9993)   (mat(i,j), j=npas*10+1,dimj)
    end do
    
9993 format (5x,10(F22.16,1x))        
  end Subroutine wrtmat_accurate
!!$============================================================
  Subroutine wrtmatE(mat, dimmaxi, dimi, dimj, iunit)  
    !------------------------------------------------------------
    ! Ecriture matrice réelle 
    ! -------- Donnes locales -----------------------------------

    Implicit none
    Integer (KIND=kd_int), intent(in) :: dimmaxi, dimi, dimj, iunit
    Real (KIND=kd_dble), dimension(dimmaxi,dimj), intent(in) :: mat
    Integer (KIND=kd_int) :: i,j,npas, kpas
    ! -------- Code ---------------------------------------------
    npas = dimj/10
    if (npas.eq.0) goto 10
    do kpas = 1,npas
       do i = 1, dimi
          write(iunit,9993)   (mat(i,j), j=(kpas-1)*10+1,kpas*10)
       end do
       write(iunit,*)
    end do
    
10  if (mod(dimj,10).eq.0) return 
    do i = 1, dimi
       write(iunit,9993)   (mat(i,j), j=npas*10+1,dimj)
    end do
    
9993 format (5x,10(E15.6,1x))        
  end Subroutine wrtmatE
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
!!$============================================================
  !> @brief Write WF determinants in formated file 
  !> @author MBL
  !> @date July  2021
!!$============================================================
  subroutine wrt_WF(ndet,nvec,first_vec,last_vec,det,vect,o_info,iunit)
    implicit none
    Integer, parameter :: pas = 5
    Integer (KIND=kd_int), intent(in)        :: ndet,nvec,first_vec,last_vec,iunit
    type(deter), dimension(ndet), intent(in) :: det
    real(kd_dble), dimension(ndet,nvec), intent(in) :: vect
    type(o_infotype), intent(in)             :: o_info
    Integer (KIND=kd_int) :: idet,j,ivec,npas, kpas, shtrou, shpart, shtu, shtd, shpu, shpd, ibit
    Character*1, dimension(2) :: spin
    Integer(KIND=kd_int), dimension(2) :: sh
    ! -------- Code ---------------------------------------------
    npas = (last_vec - first_vec + 1)/pas

    shtrou  = 2*o_info%ngel +  o_info%nocc + o_info%nligo
    shtu    = o_info%ngel
    shtd    = o_info%ngel +  o_info%nocc + o_info%nligo
    shpart  = 2*(o_info%ngel +  o_info%nocc + o_info%nligo + o_info%nact) + o_info%nligv + o_info%nvirt
    shpu    = o_info%ngel + o_info%nocc + o_info%nligo + o_info%nact
    shpd    = o_info%ngel + o_info%nocc + o_info%nligo + o_info%nact + o_info%nligv + o_info%nvirt
    
    ! if (npas.eq.0) goto 10
    ! do kpas = 1,npas
    !    do i = 1, ndet
    !       call wrtdet_local(det(i), iunit, o_info%ngel, o_info%nocc, &
    !            o_info%nligo, o_info%nact, o_info%nligv, &
    !            o_info%nvirt, o_info%ndel)
    !       write(iunit,9990)  (vect(i,ivec), ivec = first_vec + (kpas-1)*pas+1, first_vec + kpas*pas)
    !    end do
    !    write(iunit,*)
    ! end do

    ! 10  if (mod(last_vec - first_vec + 1,pas) .eq. 0) return

    
    if (npas.eq.0) goto 10
    kp : do kpas = 1,npas
Marie bernadette Lepetit's avatar
Marie bernadette Lepetit committed
496
497
       do idet = 1, ndet
          write(iunit,'(i9,2x)',advance='no') idet
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
          ! actives
          do ibit = 0,o_info%nact-1
             write(iunit,'(i1)',advance='no') ibits(det(idet)%detact, ibit, 1)
          end do
          write(iunit,'(" ")',advance='no')
          do ibit = o_info%nact, 2*o_info%nact-1
             write(iunit,'(i1)',advance='no') ibits(det(idet)%detact, ibit, 1)
          end do
          write(iunit,'(" ")',advance='no')
          ! trous
          if (det(idet)%dettr(1).eq.0) then ! 0 trou
             write(iunit,'(11x," -> ")',advance='no')
          else if (det(idet)%dettr(2).eq.0) then ! 1 trou
             if (det(idet)%dettr(1).le.shtrou) then
                spin(1)="u"
                sh(1)  = shtu
             else
                spin(1)="d"
                sh(1)  = shtd
             end if
             write(iunit,'(I4,a1,6x," -> ")',advance='no') det(idet)%dettr(1)-sh(1), spin(1)
          else ! 2 trou
             if (det(idet)%dettr(1).le.shtrou) then
                spin(:)="u"
                sh(:)  = shtu
                
524
525
526
527
528
529
530
531
532
          else if (det(idet)%dettr(2).le.shtrou) then
             spin(1)="d"
             sh(1)  = shtd
             spin(2)="u"
             sh(2)  = shtu
          else
             spin(:)="d"
             sh(:)  = shtd
          end if
533
          write(iunit,'(I4,a1,I4,a1,1x," -> ")',advance='no') (det(idet)%dettr(j)-sh(j), spin(j), j=2,1,-1)
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
       end if
       ! particules
       if (det(idet)%detprt(1).eq.0) then ! 0 particules
          write(iunit,'(11x,2x)',advance='no')
       else if (det(idet)%detprt(2).eq.0) then ! 1 particules
          if (det(idet)%detprt(1).le.shpart) then
             spin(1)="u"
             sh(1)  = shpu
          else
             spin(1)="d"
             sh(1)  = shpd
          end if
          write(iunit,'(I4,a1,6x,2x)',advance='no') det(idet)%detprt(1)-sh(1), spin(1)
       else ! 2 particules
          if (det(idet)%detprt(2).le.shpart) then
             spin(:)="u"
             sh(:)  = shpu
          else if (det(idet)%detprt(1).le.shpart) then
             spin(1)="u"
             sh(1)  = shpu
             spin(2)="d"
             sh(2)  = shpd
          else
             spin(:)="d"
             sh(:)  = shpd
          end if
560
          write(iunit,'(I4,a1,I4,a1,3x)',advance='no') (det(idet)%detprt(j)-sh(j), spin(j), j=1,2)
561
562
563
564
565
566
567
568
569
       end if
       ! vecteur
       write(iunit,9990)  (vect(idet,ivec), ivec = first_vec + (kpas-1)*pas, first_vec-1 + kpas*pas)
    end do
    write(iunit,*)
    end do kp

10  if (mod(last_vec - first_vec + 1,pas) .eq. 0) return
    do idet = 1, ndet
Marie bernadette Lepetit's avatar
Marie bernadette Lepetit committed
570
       write(iunit,'(i9,2x)',advance='no') idet
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
       ! actives
       do ibit = 0,o_info%nact-1
          write(iunit,'(i1)',advance='no') ibits(det(idet)%detact, ibit, 1)
       end do
       write(iunit,'(" ")',advance='no')
       do ibit = o_info%nact, 2*o_info%nact-1
          write(iunit,'(i1)',advance='no') ibits(det(idet)%detact, ibit, 1)
       end do
       write(iunit,'(" ")',advance='no')
       ! trous
       if (det(idet)%dettr(1).eq.0) then ! 0 trou
          write(iunit,'(11x," -> ")',advance='no')
       else if (det(idet)%dettr(2).eq.0) then ! 1 trou
          if (det(idet)%dettr(1).le.shtrou) then
             spin(1)="u"
             sh(1)  = shtu
          else
             spin(1)="d"
             sh(1)  = shtd
          end if
          write(iunit,'(I4,a1,6x," -> ")',advance='no') det(idet)%dettr(1)-sh(1), spin(1)
       else ! 2 trou
          if (det(idet)%dettr(1).le.shtrou) then
             spin(:)="u"
             sh(:)  = shtu
          else if (det(idet)%dettr(2).le.shtrou) then
             spin(1)="d"
             sh(1)  = shtd
             spin(2)="u"
             sh(2)  = shtu
          else
             spin(:)="d"
             sh(:)  = shtd
          end if
605
          write(iunit,'(I4,a1,I4,a1,1x," -> ")',advance='no') (det(idet)%dettr(j)-sh(j), spin(j), j=2,1,-1)
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
       end if
       ! particules
       if (det(idet)%detprt(1).eq.0) then ! 0 particules
          write(iunit,'(11x,2x)',advance='no')
       else if (det(idet)%detprt(2).eq.0) then ! 1 particules
          if (det(idet)%detprt(1).le.shpart) then
             spin(1)="u"
             sh(1)  = shpu
          else
             spin(1)="d"
             sh(1)  = shpd
          end if
          write(iunit,'(I4,a1,6x,2x)',advance='no') det(idet)%detprt(1)-sh(1), spin(1)
       else ! 2 particules
          if (det(idet)%detprt(2).le.shpart) then
             spin(:)="u"
             sh(:)  = shpu
          else if (det(idet)%detprt(1).le.shpart) then
             spin(1)="u"
             sh(1)  = shpu
             spin(2)="d"
             sh(2)  = shpd
          else
             spin(:)="d"
             sh(:)  = shpd
          end if
632
          write(iunit,'(I4,a1,I4,a1,3x)',advance='no') (det(idet)%detprt(j)-sh(j), spin(j), j=1,2)
633
634
635
636
637
638
       end if
       ! vecteur
       write(iunit,9990)  (vect(idet,ivec), ivec = first_vec + npas*pas, last_vec )
    end do
    write(iunit,*)
    
Marie bernadette Lepetit's avatar
Marie bernadette Lepetit committed
639
9990 format(5(2x,F20.16))
640
641
  end subroutine wrt_WF
!!$============================================================
642
643
644
645
646
!!$============================================================
End Module utils_wrt
!!$ Local Variables:
!!$   coding: utf-8-unix
!!$ End: