Subroutine open_output
379 :
380 : !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
381 : !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
382 : !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
383 :
384 : subroutine open_output (logdate, run_initialseed)
385 : use vom_sce_mod
386 : implicit none
387 :
388 : CHARACTER(24), INTENT(in) :: logdate
389 : INTEGER, INTENT(out) :: run_initialseed
390 :
391 : INTEGER :: ii, iostat
392 : CHARACTER(len=135) :: msg
393 : REAL*8, ALLOCATABLE :: tmp_8(:)
394 :
395 : run_initialseed = 0
396 :
397 : open(kfile_lastloop, FILE=trim(adjustl(i_outputpath)) // &
398 : trim(adjustl(sfile_lastloop)), STATUS='old', IOSTAT=iostat)
399 : if (iostat .eq. 0) then
400 :
401 : ! * read parameter values to continue from last run
402 :
403 : read(kfile_lastloop,*) ncomp2
404 : read(kfile_lastloop,*) nloop
405 : read(kfile_lastloop,*) nrun
406 : read(kfile_lastloop,*) nsincebest
407 : read(kfile_lastloop,loopformat) ofvec(:)
408 : ! * use temporary variable to prevent warning in ifort
409 : allocate(tmp_8(sopt))
410 : do ii = 1, vom_npar
411 : read(kfile_lastloop, loopformat) tmp_8(:)
412 : shufflevar(ii,:) = tmp_8(:)
413 : enddo
414 : deallocate(tmp_8)
415 : close(kfile_lastloop)
416 : bestobj = ofvec(1)
417 :
418 : ! * open files for storing objective function and parameter values
419 :
420 : open(kfile_sceout, FILE=trim(adjustl(i_outputpath)) // &
421 : trim(adjustl(sfile_sceout)), STATUS='old', POSITION='append')
422 : open(kfile_bestpars, FILE=trim(adjustl(i_outputpath)) // &
423 : trim(adjustl(sfile_bestpars)), STATUS='old', POSITION='append')
424 : if (kfile_progress .ne. 6) then
425 : open(kfile_progress, FILE=trim(adjustl(i_outputpath)) // &
426 : trim(adjustl(sfile_progress)), STATUS='old', POSITION='append')
427 : endif
428 : write(kfile_progress,*) " "
429 : write(msg,'(" NEW Run time: ",A)') logdate
430 : write(kfile_progress,*) TRIM(msg)
431 : else
432 :
433 : ! * open empty files for storing objective function and parameter values
434 :
435 : open(kfile_sceout, FILE=trim(adjustl(i_outputpath)) // &
436 : trim(adjustl(sfile_sceout)), STATUS='replace')
437 : open(kfile_bestpars, FILE=trim(adjustl(i_outputpath)) // &
438 : trim(adjustl(sfile_bestpars)), STATUS='replace')
439 : if (kfile_progress .ne. 6) then
440 : open(kfile_progress, FILE=trim(adjustl(i_outputpath)) // &
441 : trim(adjustl(sfile_progress)), STATUS='replace')
442 : endif
443 :
444 : ! * write output header
445 :
446 : write(kfile_progress,*) "SHUFFLED COMPLEX EVOLUTION OPTIMISER"
447 : write(kfile_progress,*) " "
448 : write(msg,'(" Run time: ",A)') logdate
449 : write(kfile_progress,*) TRIM(msg)
450 :
451 : bestobj = 0.0
452 : bestincomp = 0.0
453 : run_initialseed = 1
454 : endif
455 :
456 : return
457 : end subroutine open_output