Changeset 78e62dc in flexpart.git for src/mpi_mod.f90


Ignore:
Timestamp:
May 12, 2015, 12:28:19 PM (9 years ago)
Author:
flexpart <>
Branches:
master, 10.4.1_pesei, GFS_025, bugfixes+enhancements, dev, release-10, release-10.4.1, scaling-bug, univie
Children:
0f20c31
Parents:
2f8635b
Message:

New OH parameter in SPECIES files (now 3 instead of 2). New path to OH binariy files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mpi_mod.f90

    r5f9d14a r78e62dc  
    9090  integer :: tm1
    9191  integer, parameter :: nvar_async=27 !29 :DBG:
    92   !integer, dimension(:), allocatable :: tags
     92!integer, dimension(:), allocatable :: tags
    9393  integer, dimension(:), allocatable :: reqs
    9494
     
    117117  logical, parameter :: mp_dbg_out = .false.
    118118  logical, parameter :: mp_time_barrier=.true.
    119   logical, parameter :: mp_measure_time=.true.
     119  logical, parameter :: mp_measure_time=.false.
    120120
    121121! for measuring CPU/Wall time
     
    139139  real(dp) :: mp_conccalc_time_beg, mp_conccalc_time_end, mp_conccalc_time_total=0.
    140140  real(dp) :: mp_total_wtime_beg, mp_total_wtime_end, mp_total_wtime_total=0.
     141  real(dp) :: mp_vt_wtime_beg, mp_vt_wtime_end, mp_vt_wtime_total
     142  real(sp) :: mp_vt_time_beg, mp_vt_time_end, mp_vt_time_total
    141143
    142144! dat_lun           logical unit number for i/o
     
    418420
    419421
    420 
    421422! redefine numpart as 'numpart per process' throughout the code
    422423!**************************************************************
     
    438439
    439440    integer :: i
    440 
    441 
    442 !***********************************************************************
    443 
    444441
    445442! Time for MPI communications
     
    12431240
    12441241    do dest=0,mp_np-1 ! mp_np-2 will also work if last proc reserved for reading
    1245                       ! TODO: use mp_partgroup_np here
     1242! TODO: use mp_partgroup_np here
    12461243      if (dest.eq.id_read) cycle
    12471244      i=dest*nvar_async
     
    13391336             &MPI_COMM_WORLD,reqs(i),mp_ierr)
    13401337        if (mp_ierr /= 0) goto 600
    1341       ! else
    1342       !   i=i+2
     1338! else
     1339!   i=i+2
    13431340      end if
    13441341
     
    13891386
    13901387! :TODO: don't need these
    1391     ! d3s1=d3_size1
    1392     ! d3s2=d3_size2
    1393     ! d2s1=d2_size1
    1394     ! d2s2=d2_size2
     1388! d3s1=d3_size1
     1389! d3s2=d3_size2
     1390! d2s1=d2_size1
     1391! d2s2=d2_size2
    13951392
    13961393! At the time this immediate receive is posted, memstat is the state of
     
    15931590    call MPI_Waitall(n_req,reqs,MPI_STATUSES_IGNORE,mp_ierr)
    15941591!    endif
    1595     ! else
    1596     !   do i = 0, nvar_async*mp_np-1
    1597     !     if (mod(i,27).eq.0 .or. mod(i,28).eq.0) then
    1598     !       call MPI_Cancel(reqs(i),mp_ierr)
    1599     !       cycle
    1600     !     end if
    1601     !     call MPI_Wait(reqs(i),MPI_STATUS_IGNORE,mp_ierr)
    1602     !   end do
    1603     ! end if
     1592! else
     1593!   do i = 0, nvar_async*mp_np-1
     1594!     if (mod(i,27).eq.0 .or. mod(i,28).eq.0) then
     1595!       call MPI_Cancel(reqs(i),mp_ierr)
     1596!       cycle
     1597!     end if
     1598!     call MPI_Wait(reqs(i),MPI_STATUS_IGNORE,mp_ierr)
     1599!   end do
     1600! end if
    16041601
    16051602    if (mp_ierr /= 0) goto 600
     
    17331730           & mp_comm_used, mp_ierr)
    17341731    end if
    1735 
    17361732
    17371733    if ((WETDEP).and.(ldirect.gt.0)) then
     
    18541850      end if
    18551851
     1852    case ('verttransform')
     1853      if (imode.eq.0) then
     1854        mp_vt_wtime_beg = mpi_wtime()
     1855        call cpu_time(mp_vt_time_beg)
     1856      else
     1857        mp_vt_wtime_end = mpi_wtime()
     1858        call cpu_time(mp_vt_time_end)
     1859
     1860        mp_vt_wtime_total = mp_vt_wtime_total + (mp_vt_wtime_end - &
     1861             & mp_vt_wtime_beg)
     1862        mp_vt_time_total = mp_vt_time_total + (mp_vt_time_end - &
     1863             & mp_vt_time_beg)
     1864      end if
     1865
    18561866    case ('readwind')
    18571867      if (imode.eq.0) then
     
    19091919!***********************************************************************
    19101920
    1911     if (mp_measure_time) then
     1921    IF (mp_measure_time) THEN
    19121922      do ip=0, mp_np-1
    19131923        call MPI_BARRIER(MPI_COMM_WORLD, mp_ierr)
     
    19561966          write(*,FMT='(A60,TR1,F9.2)') 'TOTAL WALL TIME FOR CONCCALC:',&
    19571967               & mp_conccalc_time_total
     1968          ! write(*,FMT='(A60,TR1,F9.2)') 'TOTAL WALL TIME FOR VERTTRANSFORM:',&
     1969          !      & mp_vt_wtime_total
     1970          ! write(*,FMT='(A60,TR1,F9.2)') 'TOTAL CPU TIME FOR VERTTRANSFORM:',&
     1971          !      & mp_vt_time_total
    19581972! NB: the 'flush' function is possibly a gfortran-specific extension
    19591973          call flush()
     
    19621976    end if
    19631977
     1978! This call to barrier is for correctly formatting output
     1979    call MPI_BARRIER(MPI_COMM_WORLD, mp_ierr)
     1980
     1981    if (lroot) then
     1982      write(*,FMT='(72("#"))')
     1983      WRITE(*,*) "To turn off output of time measurements, set "
     1984      WRITE(*,*) "    mp_measure_time=.false."
     1985      WRITE(*,*) "in file mpi_mod.f90"
     1986      write(*,FMT='(72("#"))')
     1987    end if
     1988
    19641989! j=mp_pid*nvar_async
    19651990! In the implementation with 3 fields, the processes may have posted
    19661991! MPI_Irecv requests that should be cancelled here
    19671992!! TODO:
    1968     ! if (.not.lmp_sync) then
    1969     !   r=mp_pid*nvar_async
    1970     !   do j=r,r+nvar_async-1
    1971     !     call MPI_Cancel(j,mp_ierr)
    1972     !     if (mp_ierr /= 0) write(*,*) '#### mpif_finalize::MPI_Cancel> ERROR ####'
    1973     !   end do
    1974     ! end if
     1993! if (.not.lmp_sync) then
     1994!   r=mp_pid*nvar_async
     1995!   do j=r,r+nvar_async-1
     1996!     call MPI_Cancel(j,mp_ierr)
     1997!     if (mp_ierr /= 0) write(*,*) '#### mpif_finalize::MPI_Cancel> ERROR ####'
     1998!   end do
     1999! end if
    19752000
    19762001    call MPI_FINALIZE(mp_ierr)
     
    19812006
    19822007
    1983   end subroutine mpif_finalize
    1984 
    1985 
    1986   subroutine get_lun(my_lun)
     2008    end subroutine mpif_finalize
     2009
     2010
     2011    subroutine get_lun(my_lun)
    19872012!***********************************************************************
    19882013! get_lun:
     
    19902015!***********************************************************************
    19912016
    1992     implicit none
    1993 
    1994     integer, intent(inout) :: my_lun
    1995     integer, save :: free_lun=100
    1996     logical :: exists, iopen
    1997 
    1998 !***********************************************************************
    1999 
    2000     loop1: do
    2001       inquire(UNIT=free_lun, EXIST=exists, OPENED=iopen)
    2002       if (exists .and. .not.iopen) exit loop1
    2003       free_lun = free_lun+1
    2004     end do loop1
    2005     my_lun = free_lun
    2006 
    2007   end subroutine get_lun
    2008 
    2009 
    2010   subroutine write_data_dbg(array_in, array_name, tstep, ident)
    2011 !***********************************************************************
    2012 ! Write one-dimensional arrays to disk (for debugging purposes)
    2013 !***********************************************************************
    2014     implicit none
    2015 
    2016     real, intent(in), dimension(:) :: array_in
    2017     integer, intent(in) :: tstep
    2018     integer :: lios
    2019     character(LEN=*), intent(in) :: ident, array_name
    2020 
    2021     character(LEN=8) :: c_ts
    2022     character(LEN=40) :: fn_1, fn_2
    2023 
    2024 !***********************************************************************
    2025 
    2026     write(c_ts, FMT='(I8.8,BZ)') tstep
    2027     fn_1='-'//trim(adjustl(c_ts))//'-'//trim(ident)
    2028     write(c_ts, FMT='(I2.2,BZ)') mp_np
    2029     fn_2= trim(adjustl(array_name))//trim(adjustl(fn_1))//'-np'//trim(adjustl(c_ts))//'.dat'
    2030 
    2031     call get_lun(dat_lun)
    2032     open(UNIT=dat_lun, FILE=fn_2, IOSTAT=lios, ACTION='WRITE', &
    2033          FORM='UNFORMATTED', STATUS='REPLACE')
    2034     write(UNIT=dat_lun, IOSTAT=lios) array_in
    2035     close(UNIT=dat_lun)
    2036 
    2037   end subroutine write_data_dbg
     2017      implicit none
     2018
     2019      integer, intent(inout) :: my_lun
     2020      integer, save :: free_lun=100
     2021      logical :: exists, iopen
     2022
     2023!***********************************************************************
     2024
     2025      loop1: do
     2026        inquire(UNIT=free_lun, EXIST=exists, OPENED=iopen)
     2027        if (exists .and. .not.iopen) exit loop1
     2028        free_lun = free_lun+1
     2029      end do loop1
     2030      my_lun = free_lun
     2031
     2032    end subroutine get_lun
     2033
     2034
     2035    subroutine write_data_dbg(array_in, array_name, tstep, ident)
     2036!***********************************************************************
     2037! Write one-dimensional arrays to file (for debugging purposes)
     2038!***********************************************************************
     2039      implicit none
     2040
     2041      real, intent(in), dimension(:) :: array_in
     2042      integer, intent(in) :: tstep
     2043      integer :: lios
     2044      character(LEN=*), intent(in) :: ident, array_name
     2045
     2046      character(LEN=8) :: c_ts
     2047      character(LEN=40) :: fn_1, fn_2
     2048
     2049!***********************************************************************
     2050
     2051      write(c_ts, FMT='(I8.8,BZ)') tstep
     2052      fn_1='-'//trim(adjustl(c_ts))//'-'//trim(ident)
     2053      write(c_ts, FMT='(I2.2,BZ)') mp_np
     2054      fn_2= trim(adjustl(array_name))//trim(adjustl(fn_1))//'-np'//trim(adjustl(c_ts))//'.dat'
     2055
     2056      call get_lun(dat_lun)
     2057      open(UNIT=dat_lun, FILE=fn_2, IOSTAT=lios, ACTION='WRITE', &
     2058           FORM='UNFORMATTED', STATUS='REPLACE')
     2059      write(UNIT=dat_lun, IOSTAT=lios) array_in
     2060      close(UNIT=dat_lun)
     2061
     2062    end subroutine write_data_dbg
    20382063
    20392064
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG