subroutine maxlik_init(nvarr,xrange,comm) c Optimize the UNRES energy function by minimization of a quartic target c function or by the VMC method. implicit none #ifndef ISNAN external proc_proc #endif #ifdef WINPGI cMS$ATTRIBUTES C :: proc_proc #endif include "DIMENSIONS" include "DIMENSIONS.ZSCOPT" #ifdef MPI include "mpif.h" integer IERROR,ERRCODE,kolor,key,comm include "COMMON.MPI" #endif include "COMMON.IOUNITS" include "COMMON.OPTIM" include "COMMON.XBOUND" integer nvarr,iparm double precision rr,x(max_paropt) integer idumm integer i double precision xrange(maxvar,2) integer number_of_variables common /patch/ number_of_variables #ifdef PYTHON Cf2py intent(in) comm Cf2py intent(out) nvarr Cf2Py intent(out) xrange #endif print *,"Starting..." #ifdef MPI #ifndef PYTHON c print *,"Initializing MPI..." call MPI_Init( IERROR ) ALL_COMM = MPI_COMM_WORLD #else ALL_COMM = comm print *,"comm",comm #endif print *,"Before MPI_Comm_rank" call MPI_Comm_rank( ALL_COMM, me, IERROR ) print *,"After MPI_Comm_rank" call MPI_Comm_size( ALL_COMM, nprocs, IERROR ) print *,"Finished initializing MPI... nprocs",nprocs Master = 0 Master1 = 1 c print *,"Me",me," Master",master," Ierror",ierror #ifndef PYTHON if (me.eq.Master .and. ierror.gt.0) then write(iout,*) "SEVERE ERROR - Can't initialize MPI." call mpi_finalize(ierror) stop endif #endif #endif #ifndef ISNAN c NaNQ initialization i=-1 rr=dacos(100.0d0) #ifdef WINPGI idumm=proc_proc(rr,i) #else call proc_proc(rr,i) #endif #endif call initialize c print *,"calling openunits" call openunits c print *,"openunits called" call read_general_data(*10) if (me.eq.Master) then write (iout,'(80(1h-)/10x, & "Maximum likelihood optimization of UNRES energy function", & " v. 05/10/16"/80(1h-))') call flush(iout) call cinfo endif c call promienie(*10) if (me.eq.Master)write (iout,*) "Finished READ_GENERAL_DATA" call flush(iout) do iparm=1,nparmset call parmread(iparm,*10) enddo if (me.eq.Master) write (iout,*) "Finished parmread" call flush(iout) call read_optim_parm(*10) call print_general_data(*10) call read_protein_data(*10) if (me.eq.Master) write (iout,*) "Finished READ_PROTEIN_DATA" call flush(iout) call read_database(*10) if (me.eq.Master) write (iout,*) "Finished READ_DATABASE" call flush(iout) #ifdef MPI c write (iout,*) Me,' calling PROC_GROUPS' call proc_groups c write (iout,*) Me,' calling WORK_PARTITION_MAP' c call work_partition_map(nvarr) #endif call proc_data(nvarr,x,*10) #ifdef PYTHON number_of_variables=nvarr do i=1,nvarr xrange(i,1)=x_low(i) xrange(i,2)=x_up(i) enddo if (me.eq.Master) write (iout,*) "xrange from MAXLIK_INIT" do i=1,nvarr if (me.eq.Master) write (iout,*) i,xrange(i,1),xrange(i,2) enddo if (me.eq.Master) & write (iout,*) "================ maxlik intiialization completed" call flush (iout) #endif call read_thermal return 10 if (me.eq.Master)write (iout,*) "Error termination of the program" call MPI_Finalize( IERROR ) return end c------------------------------------------------------------------------ subroutine maxlik_optim(x,xmin,fmin) c Optimize the UNRES energy function by minimization of a quartic target c function or by the VMC method. implicit none #ifndef ISNAN external proc_proc #endif #ifdef WINPGI cMS$ATTRIBUTES C :: proc_proc #endif include "DIMENSIONS" include "DIMENSIONS.ZSCOPT" #ifdef MPI include "mpif.h" integer IERROR,ERRCODE,kolor,key include "COMMON.MPI" #endif include "COMMON.IOUNITS" include "COMMON.OPTIM" integer nvarr,iparm,i double precision rr,x(max_paropt),xmin(max_paropt),fmin double precision tcpu,t1,t1w,t1_ini,t1w_ini integer number_of_variables common /patch/ number_of_variables nvarr=number_of_variables #ifdef PYTHON Cf2py intent(in) x Cf2py intent(out) xmin Cf2py intent(out) fmin if (me.eq.Master) then write (*,*) "MAXLIK_OPTIM: Variables from PYTHON:",nvarr write (iout,*) "MAXLIK_OPTIM: Variables from PYTHON:",nvarr do i=1,nvarr write (iout,*) i,x(i) enddo endif #else if (me.eq.Master) then write (*,*) "MAXLIK_OPTIM: Variables from maxlik_init:",nvarr write (iout,*) "MAXLIK_OPTIM: Variables from maxlik_init:",nvarr do i=1,nvarr write (iout,*) i,x(i) enddo endif #endif #ifdef MPI if (me.eq.Master) then t1w_ini = MPI_WTIME() t1_ini = tcpu() #endif call maxlikopt(nvarr,x,xmin,fmin) write (iout,*) "fmin from MAXLIK_OPTIM:",fmin #ifdef MPI call jebadelko(nvarr) else call jebadelko(nvarr) endif call bilans if (me.eq.Master) then t1w = mpi_wtime() - t1w_ini t1 = tcpu() - t1_ini write (iout,*) write (iout,*) "CPU time",t1," wall clock time",t1w call flush(iout) endif #ifdef PYTHON if (me.eq.Master) & write (iout,'(30(1h-),"Minimization completed",30(1h-))') call flush(iout) #else call MPI_Finalize( IERROR ) #endif #else call bilans #endif return end