1 subroutine maxlik_init(nvarr,xrange,comm,mepython)
2 c Optimize the UNRES energy function by minimization of a quartic target
3 c function or by the VMC method.
9 cMS$ATTRIBUTES C :: proc_proc
12 include "DIMENSIONS.ZSCOPT"
15 integer IERROR,ERRCODE,kolor,key,comm
18 include "COMMON.IOUNITS"
19 include "COMMON.OPTIM"
20 include "COMMON.XBOUND"
21 integer nvarr,iparm,mepython
22 double precision rr,x(max_paropt)
25 double precision xrange(maxvar,2)
26 integer number_of_variables
27 common /patch/ number_of_variables
30 Cf2py intent(in) mepython
31 Cf2py intent(out) nvarr
32 Cf2Py intent(out) xrange
37 c print *,"Initializing MPI..."
38 call MPI_Init( IERROR )
39 ALL_COMM = MPI_COMM_WORLD
44 print *,"Before MPI_Comm_rank"
45 call MPI_Comm_rank( ALL_COMM, me, IERROR )
46 print *,"After MPI_Comm_rank"
47 call MPI_Comm_size( ALL_COMM, nprocs, IERROR )
48 print *,"Finished initializing MPI... nprocs",nprocs
51 c print *,"Me",me," Master",master," Ierror",ierror
53 if (me.eq.Master .and. ierror.gt.0) then
54 write(iout,*) "SEVERE ERROR - Can't initialize MPI."
55 call mpi_finalize(ierror)
71 c print *,"calling openunits"
72 call openunits(mepython)
73 c print *,"openunits called"
74 call read_general_data(*10)
75 if (me.eq.Master) then
76 write (iout,'(80(1h-)/10x,
77 & "Maximum likelihood optimization of UNRES energy function",
78 & " v. 05/10/16"/80(1h-))')
80 write (iout,*) "My Python task is",mepython
81 write (*,*) "My rank is",me," My Python task is",mepython
87 if (me.eq.Master)write (iout,*) "Finished READ_GENERAL_DATA"
90 call parmread(iparm,*10)
92 if (me.eq.Master) write (iout,*) "Finished parmread"
94 call read_optim_parm(*10)
95 call print_general_data(*10)
96 call read_protein_data(*10)
97 if (me.eq.Master) write (iout,*) "Finished READ_PROTEIN_DATA"
100 if (mepython.gt.0) call read_database(*10)
102 call read_database(*10)
104 if (me.eq.Master) then
105 write (iout,*) "Finished READ_DATABASE"
109 c write (iout,*) Me,' calling PROC_GROUPS'
111 c write (iout,*) Me,' calling WORK_PARTITION_MAP'
112 c call work_partition_map(nvarr)
114 call proc_data(nvarr,x,mepython,*10)
116 number_of_variables=nvarr
121 if (me.eq.Master) write (iout,*) "xrange from MAXLIK_INIT"
123 if (me.eq.Master) write (iout,*) i,xrange(i,1),xrange(i,2)
126 & write (iout,*) "================ maxlik intiialization completed"
128 if (mepython.eq.0) then
130 & "I am PYTHON master and this is the end of my FORTRAN task."
137 10 if (me.eq.Master)write (iout,*) "Error termination of the program"
138 call MPI_Finalize( IERROR )
141 c------------------------------------------------------------------------
142 subroutine maxlik_optim(x,xmin,fmin)
143 c Optimize the UNRES energy function by minimization of a quartic target
144 c function or by the VMC method.
150 cMS$ATTRIBUTES C :: proc_proc
153 include "DIMENSIONS.ZSCOPT"
156 integer IERROR,ERRCODE,kolor,key
159 include "COMMON.IOUNITS"
160 include "COMMON.OPTIM"
161 integer nvarr,iparm,i
162 double precision rr,x(max_paropt),xmin(max_paropt),fmin
163 double precision tcpu,t1,t1w,t1_ini,t1w_ini
164 integer number_of_variables
165 common /patch/ number_of_variables
166 nvarr=number_of_variables
169 Cf2py intent(out) xmin
170 Cf2py intent(out) fmin
171 if (me.eq.Master) then
172 write (*,*) "MAXLIK_OPTIM: Variables from PYTHON:",nvarr
173 write (iout,*) "MAXLIK_OPTIM: Variables from PYTHON:",nvarr
175 write (iout,*) i,x(i)
179 if (me.eq.Master) then
180 write (*,*) "MAXLIK_OPTIM: Variables from maxlik_init:",nvarr
181 write (iout,*) "MAXLIK_OPTIM: Variables from maxlik_init:",nvarr
183 write (iout,*) i,x(i)
188 if (me.eq.Master) then
189 t1w_ini = MPI_WTIME()
192 call maxlikopt(nvarr,x,xmin,fmin)
193 write (iout,*) "fmin from MAXLIK_OPTIM:",fmin
195 call jebadelko(nvarr)
197 call jebadelko(nvarr)
200 if (me.eq.Master) then
201 t1w = mpi_wtime() - t1w_ini
204 write (iout,*) "CPU time",t1," wall clock time",t1w
209 & write (iout,'(30(1h-),"Minimization completed",30(1h-))')
212 call MPI_Finalize( IERROR )