Changeset b069789 in flexpart.git for src/concoutput_mpi.f90


Ignore:
Timestamp:
Oct 16, 2015, 11:31:33 AM (9 years ago)
Author:
Espen Sollum ATMOS <eso@…>
Branches:
master, 10.4.1_pesei, GFS_025, bugfixes+enhancements, dev, release-10, release-10.4.1, scaling-bug, univie
Children:
c04b739
Parents:
43225d1
Message:

If the 'dates' file exists on simulation start, backup to 'dates.bak' and create new file 'dates' instead of appending to it

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/concoutput_mpi.f90

    r478e9e6 rb069789  
    106106  character(len=3) :: anspec
    107107  integer :: mind
    108 ! mind        eso:added to ensure identical results between 2&3-fields versions
    109   CHARACTER(LEN=8),save :: file_stat='REPLACE'
     108! mind        eso: added to ensure identical results between 2&3-fields versions
     109  character(LEN=8),save :: file_stat='REPLACE'
     110  logical :: ldates_file
     111  integer :: ierr
     112  character(LEN=100) :: dates_char
     113!  character :: dates_char
    110114
    111115! Measure execution time
    112116  if (mp_measure_time) call mpif_mtime('rootonly',0)
    113 
    114117
    115118! Determine current calendar date, needed for the file name
     
    120123  write(adate,'(i8.8)') jjjjmmdd
    121124  write(atime,'(i6.6)') ihmmss
    122   OPEN(unitdates,file=path(2)(1:length(2))//'dates', ACCESS='APPEND', STATUS=file_stat)
     125
     126! Overwrite existing dates file on first call, later append to it
     127! This fixes a bug where the dates file kept growing across multiple runs
     128
     129! If 'dates' file exists, make a backup
     130  inquire(file=path(2)(1:length(2))//'dates', exist=ldates_file)
     131  if (ldates_file.and.init) then
     132    open(unit=unitdates, file=path(2)(1:length(2))//'dates',form='formatted', &
     133         &access='sequential', status='old', action='read', iostat=ierr)
     134    open(unit=unittmp, file=path(2)(1:length(2))//'dates.bak', access='sequential', &
     135         &status='replace', action='write', form='formatted', iostat=ierr)
     136    do while (.true.)
     137      read(unitdates, '(a)', iostat=ierr) dates_char
     138      if (ierr.ne.0) exit
     139      write(unit=unittmp, fmt='(a)', iostat=ierr, advance='yes') trim(dates_char)
     140!      if (ierr.ne.0) write(*,*) "Write error, ", ierr
     141    end do
     142    close(unit=unitdates)
     143    close(unit=unittmp)
     144  end if
     145
     146  open(unitdates,file=path(2)(1:length(2))//'dates', ACCESS='APPEND', STATUS=file_stat)
    123147  write(unitdates,'(a)') adate//atime
    124148  close(unitdates) 
     
    126150  ! Overwrite existing dates file on first call, later append to it
    127151  ! This fixes a bug where the dates file kept growing across multiple runs
    128   ! TODO check if the 'always APPEND'-behaviour is useful in other scenarioes
    129   ! e.g. (restart?)
    130152  IF (init) THEN
    131153    file_stat='OLD'
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG