N.I.M.R.O.D.  

nimrod.f90

Go to the documentation of this file.
00001 
00088 
00089 
00090 
00091 
00092 !------------------------------------------------------------------------------
00093 ! N.I.M.R.O.D. - Normal approximation Inference in Models with Random
00094 !                effects based on Ordinary Differential equations
00095 !------------------------------------------------------------------------------
00096 !
00097 ! VERSION : 1.0
00098 !
00099 ! MODULE: nimrod.f90
00100 !
00119 program nimrod
00120     use WorkingSharedValues
00121     use mpimod
00122     implicit none
00123 
00124     double precision, dimension(npm) ::b,brelance
00125     double precision, dimension(3) :: conv
00126     double precision,dimension(npm*(npm+3)/2)::V
00127     double precision :: vrais,rl,funcpa,tpscpubegin,tpscpufinish,tpscpu,LCV_a,VraisNP
00128     integer :: istop,ni,compteurRelance,nitot,i
00129     character(len=20)::numrelance
00130 
00131     call MPIinitialisation
00132 
00133     nitot=0
00134     istop=0
00135     compteurRelance=1
00136 
00137     call cpu_time (tpscpubegin)
00138 
00139     ! READING FILES
00140     call InputReading()
00141     ! CREATION OF WORKING DIRECTORIES
00142     if(numproc.EQ.0)call system ("rm -rf "//trim(adjustl(OutputFolder)))
00143     if(numproc.EQ.0)call system ("mkdir "//trim(adjustl(OutputFolder)))
00144     if(numproc.EQ.0)call system ("cp ./Input.txt ./"//trim(adjustl(OutputFolder))//"/")
00145     if(numproc.EQ.0)call system ("mkdir ./"//trim(adjustl(OutputFolder))//"/graphics/")
00146     call MPIattente
00147     ! CREATE SUMMARY FILE
00148     if((numproc.EQ.0))open(1234,file="./"// &
00149                           trim(adjustl(OutputFolder))//"/Summary.txt")
00150 123 continue
00151 
00152 
00153     ! *** Data and variables Reading and initialization
00154     call WorkingSharedValuesInit()
00155     call InputReading()
00156     call readData()
00157     call ODEschedule()
00158 
00159 
00160     if ((numproc.EQ.0).and.(LOG_PRINT)) write(0,*)"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
00161     if ((numproc.EQ.0).and.(LOG_PRINT)) write(0,'(A,i3,A)')"CCCCCCC   OPTIMIZATION NUMBER : ", compteurRelance ,"   CCCCCCC"
00162     if ((numproc.EQ.0).and.(LOG_PRINT)) write(0,*)"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
00163     if((numproc.EQ.0))write(1234,*) &
00164         "ni NPLL PLL NPLLExcl PLLExcl nbpatOK CA CB RDM LCVA IER RVS ",(nomparams(i),i=1,npm),("var"//nomparams(i),i=1,npm)
00165     b=binit
00166     if (istop.EQ.4) b=brelance
00167 
00168     ! *** Optimization is performed if and only if it is requested by the user in the Input file.
00169     if (estimationWanted) then
00170         ! *** Output file creation
00171         write(numrelance,*)compteurRelance
00172         nomfileOut=trim(adjustl("Output"//'_'//trim(adjustl(numrelance))//'.txt'))
00173         open(999,file=trim(adjustl(nomfileOut)))
00174         ! *** Optimization
00175         call optim(b,npm,ni,V,Vrais,istop,conv,VraisNP,LCV_a,compteurRelance)
00176         flush(999)
00177     end if
00178     nitot=nitot+ni
00179     if (istop.EQ.4 .and. compteurRelance.LE.maxrelance) then
00180         compteurRelance=compteurRelance+1
00181         brelance=b
00182         goto 123
00183     end if
00184 
00185     ! Computation time
00186     call cpu_time (tpscpufinish)
00187     tpscpu=tpscpufinish-tpscpubegin
00188 
00189     ! *** Latex output file writing
00190     if (estimationWanted) then
00191         call OutputFileCreation(b,v,nitot,istop,conv,Vrais,VraisNP,LCV_a,tpscpu)
00192         if ((numproc.EQ.0).and.(LOG_PRINT)) write(0,*)"**********************************************"
00193         if ((numproc.EQ.0).and.(LOG_PRINT)) write(0,*)"     OPTIMIZATION / ESTIMATION RESULTS"
00194         if ((numproc.EQ.0).and.(LOG_PRINT)) write(0,*)"*********************************************"
00195         if ((numproc.EQ.0).and.(LOG_PRINT)) write(0,*)'********************************************'
00196         if ((numproc.EQ.0).and.(LOG_PRINT)) write(0,*)'parameters',b(1:npm)
00197         if ((numproc.EQ.0).and.(LOG_PRINT)) write(0,*)"Temps d'estimation : ",tpscpu
00198         if ((numproc.EQ.0).and.(LOG_PRINT)) write(0,*)'********************************************'
00199     end if
00200 
00201     ! Close FIles
00202     if((numproc.EQ.0))close(1234)
00203     call MPIattente
00204     if ((numproc.EQ.0).and.(LOG_PRINT)) write(0,*)"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
00205     if ((numproc.EQ.0).and.(LOG_PRINT)) write(0,*)"CCCCCCC      EMPIRICAL BAYES       CCCCCCCC"
00206     if ((numproc.EQ.0).and.(LOG_PRINT)) write(0,*)"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
00207     withexclusion=.false.
00208     call EmpiricalBayesEstimation(b)
00209     call EBCurves(b)
00210     call writeFile_bayes()
00211 
00212     ! GRAPHICS
00213     if((numproc.EQ.0).and.(GRAPHICS)) then
00214          call  TraceR(b)
00215          call system("Rscript ./"//trim(adjustl(OutputFolder))//"/graphics/programR.txt")
00216     end if
00217     call MPIattente
00218 
00219     ! FILE TO RESTART COMPUTATIONS
00220     if (numproc.EQ.0) call CreateRelanceFile(b)
00221 
00222     call cpu_time (tpscpufinish)
00223     tpscpu=tpscpufinish-tpscpubegin
00224     if ((numproc.EQ.0).and.(LOG_PRINT)) write(0,*)"TEMPS TOTAL DEXECUTION : ",tpscpu
00225 
00226 
00227     call MPIattente
00228     if (estimationWanted) close(999)
00229     call MPIfinalisation
00230     stop
00231 end program nimrod
00232 
00283 
00284 
00479 
00510 
00572 
00573 
00637 
00638 
00639 
00732 
00733 
00737 
00738