File: flowqsdmin.F

package info (click to toggle)
aces3 3.0.6-7
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 82,460 kB
  • sloc: fortran: 225,647; ansic: 20,413; cpp: 4,349; makefile: 953; sh: 137
file content (159 lines) | stat: -rw-r--r-- 5,460 bytes parent folder | download | duplicates (6)
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
51
52
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
157
158
159
C  Copyright (c) 2003-2010 University of Florida
C
C  This program is free software; you can redistribute it and/or modify
C  it under the terms of the GNU General Public License as published by
C  the Free Software Foundation; either version 2 of the License, or
C  (at your option) any later version.

C  This program is distributed in the hope that it will be useful,
C  but WITHOUT ANY WARRANTY; without even the implied warranty of
C  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
C  GNU General Public License for more details.

C  The GNU General Public License is included in this distribution
C  in the file COPYRIGHT.
      subroutine flowqsdmin(scratch, grad, ehess, eigvh, dmr1, dmr2,
     &                      stp, eps, nx, ndim, ncycle)
c
c This subroutine implements the quadratic gradient descent
c algorithm of J.-Q. Sun and K.Ruedenberg in JCP 99, 5257 (1993).
c
      implicit double precision(a-h, o-z)
#include "fnamelen.par"
      character*(fnamelen) fname
      logical yesno, update, nwtonrpson, negeval, genstpsz
c
      dimension scratch(nx*nx), grad(ndim), ehess(ndim, ndim), 
     &          eigvh(ndim, ndim), dmr1(ndim, ndim), dmr2(ndim,ndim)
c
c find the eigenvalues and eigenvectors of the hessian to build the
c solution to eqn. 11 in Sun & Ruedenberg.
c
      call eig(ehess, eigvh, ndim, ndim, 1)
c
c Find the tangential vector, the scalar curvature, and define some
c ad hoc factors from Sun & Ruedenburg.
c
      update     = .false.
      nwtonrpson = .false.
      negeval    = .false.
      genstpsz    = .true.
      unew    = 0.0d0
      u_upper = 0.0d0
      u_lower = 0.0d0
      hvalue  = 0.0d0
      anu     = 5.0d0/6.0d0
c
      call qsdline(scratch, ehess, eigvh, dmr1, dmr2, unew, u_upper,
     &             u_lower, hvalue, curvtre, ndim, nx, update,
     &             nwtonrpson, negeval, genstpsz)
c
c construct the curvature dependent step size (eqn. 20b)
c
      crvdstsz = 0.25d0 + (0.75d0)/(1.d0 + 3.0d0*curvtre**anu)
      Write(6, *) "The value of curv =", curvtre
      eh = 0.3d0*crvdstsz
      Write(6, *) "The value of stpsize = ", eh
c      
c
c       if (ncycle .eq. 1) then
c
c P_0=Q_0=R_0 at the initial point. Calculate P* and Q_1 and 
c Save P*
c
c           call xdcopy(ndim, scratch(1), 1, scratch(1 + 2*ndim), 1)
           
c          call getptspqr(scratch, ehess, eigvh, dmr1, dmr2, 
c     &                  (eh/2)**2, eps, nx, ndim)
c
c          open(unit = 99, file = "QSDPINTS", form = "formatted")
c          write(99, 999) eh
c          write(99, 9999) (scratch(i + 2*ndim), i = 1, ndim)
c
c Get the Q_1 based on P*
c
          call getptspqr(scratch, ehess, eigvh, dmr1, dmr2, 
     &                   (eh/2.0d0), eps, nx, ndim)

c          call vadd(scratch(1 + 2*ndim), scratch(1 + 2*ndim), 
c     &              scratch(1), ndim, -1.0d0)
c
c          call xdcopy(ndim, scratch(1 + 2*ndim), 1, scratch(1 + ndim),
c     &               1)
c
c       else if (ncycle .eq. 2) then
c
c Calculate R_1 based on P*
c             
c          call gfname('QSDPINTS', fname, ilength)
c          inquire(file=fname(1:ilength), exist=yesno)
c          if (yesno) open(unit = 99, file = "QSDPINTS", 
c     &                    form = "formatted", status ="old")
c
c          read(99, 999) ehp
c          read(99, 9999) (scratch(i + 2*ndim), i = 1, ndim)
c          call getptspqr(scratch, ehess, eigvh, dmr1, dmr2, 
c     &                   (ehp/4.0d0)**2, eps, nx, ndim)
c
c Calculate P_1 based on Q_1
c
c          call xdcopy(ndim, scratch(1), 1, scratch(1 + 2*ndim), 1)
c          call getptspqr(scratch, ehess, eigvh, dmr1, dmr2, 
c     &                  (ehp/2.0d0)**2, eps, nx, ndim)
c          rewind(99)
c          write(99, 999) eh
c          write(99, 9999) (scratch(i + 2*ndim), i = 1, ndim)
c
c Calculate Q_2 based on P_1
c
c          call getptspqr(scratch, ehess, eigvh, dmr1, dmr2, 
c     &                  (eh/2.0d0)**2, eps, nx, ndim)
c
c          call vadd(scratch(1 + 2*ndim), scratch(1 + 2*ndim), 
c     &             scratch(1), ndim, -1.0d0)
c
c          call xdcopy(ndim, scratch(1 + 2*ndim), 1, scratch(1 + ndim),
c     &               1)
c
c       else
c
c Calculate R_n based on P_n-1
c
c          call gfname('QSDPINTS', fname, ilength)
c          inquire(file=fname(1:ilength), exist=yesno)
c          if (yesno) open(unit = 99, file = "QSDPINTS", 
c     &                    form = "formatted", status="old")
c
c          read(99, 999) ehp
c          read(99, 9999) (scratch(i + 2*ndim), i = 1, ndim)
c          call getptspqr(scratch, ehess, eigvh, dmr1, dmr2, 
c     &                  (ehp/2.0d0)**2, eps, nx, ndim)
c
c Calculate P_n based on Q_n
c
c          call xdcopy(ndim, scratch(1), 1, scratch(1 + 2*ndim), 1)
c          call getptspqr(scratch, ehess, eigvh, dmr1, dmr2, 
c     &                  (eh/2.0d0)**2, eps, nx, ndim)
c          rewind(99)
c          write(99, 999) eh
c          write(99, 9999) (scratch(i + 2*ndim), i = 1, ndim)
c
c Calculate Q_n+1 based on P_n
c
c          call getptspqr(scratch, ehess, eigvh, dmr1, dmr2, 
c     &                  (eh/2.0d0)**2, eps, nx, ndim)
c
c           call vadd(scratch(1 + 2*ndim), scratch(1 + 2*ndim), 
c     &             scratch(1), ndim, -1.0d0)
c
c           call xdcopy(ndim, scratch(1 + 2*ndim), 1, 
c     &                scratch(1 + ndim), 1)
c
c
c      endif
c       
 999    format(1x, f15.8)
 9999   format(1x, 3(f15.8, 1x))
c        
       return
       end