Changeset 78e62dc in flexpart.git for src/mpi_mod.f90
- Timestamp:
- May 12, 2015, 12:28:19 PM (9 years ago)
- Branches:
- master, 10.4.1_pesei, GFS_025, bugfixes+enhancements, dev, release-10, release-10.4.1, scaling-bug, univie
- Children:
- 0f20c31
- Parents:
- 2f8635b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mpi_mod.f90
r5f9d14a r78e62dc 90 90 integer :: tm1 91 91 integer, parameter :: nvar_async=27 !29 :DBG: 92 92 !integer, dimension(:), allocatable :: tags 93 93 integer, dimension(:), allocatable :: reqs 94 94 … … 117 117 logical, parameter :: mp_dbg_out = .false. 118 118 logical, parameter :: mp_time_barrier=.true. 119 logical, parameter :: mp_measure_time=. true.119 logical, parameter :: mp_measure_time=.false. 120 120 121 121 ! for measuring CPU/Wall time … … 139 139 real(dp) :: mp_conccalc_time_beg, mp_conccalc_time_end, mp_conccalc_time_total=0. 140 140 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 141 143 142 144 ! dat_lun logical unit number for i/o … … 418 420 419 421 420 421 422 ! redefine numpart as 'numpart per process' throughout the code 422 423 !************************************************************** … … 438 439 439 440 integer :: i 440 441 442 !***********************************************************************443 444 441 445 442 ! Time for MPI communications … … 1243 1240 1244 1241 do dest=0,mp_np-1 ! mp_np-2 will also work if last proc reserved for reading 1245 1242 ! TODO: use mp_partgroup_np here 1246 1243 if (dest.eq.id_read) cycle 1247 1244 i=dest*nvar_async … … 1339 1336 &MPI_COMM_WORLD,reqs(i),mp_ierr) 1340 1337 if (mp_ierr /= 0) goto 600 1341 1342 1338 ! else 1339 ! i=i+2 1343 1340 end if 1344 1341 … … 1389 1386 1390 1387 ! :TODO: don't need these 1391 1392 1393 1394 1388 ! d3s1=d3_size1 1389 ! d3s2=d3_size2 1390 ! d2s1=d2_size1 1391 ! d2s2=d2_size2 1395 1392 1396 1393 ! At the time this immediate receive is posted, memstat is the state of … … 1593 1590 call MPI_Waitall(n_req,reqs,MPI_STATUSES_IGNORE,mp_ierr) 1594 1591 ! endif 1595 1596 1597 1598 1599 1600 1601 1602 1603 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 1604 1601 1605 1602 if (mp_ierr /= 0) goto 600 … … 1733 1730 & mp_comm_used, mp_ierr) 1734 1731 end if 1735 1736 1732 1737 1733 if ((WETDEP).and.(ldirect.gt.0)) then … … 1854 1850 end if 1855 1851 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 1856 1866 case ('readwind') 1857 1867 if (imode.eq.0) then … … 1909 1919 !*********************************************************************** 1910 1920 1911 if (mp_measure_time) then1921 IF (mp_measure_time) THEN 1912 1922 do ip=0, mp_np-1 1913 1923 call MPI_BARRIER(MPI_COMM_WORLD, mp_ierr) … … 1956 1966 write(*,FMT='(A60,TR1,F9.2)') 'TOTAL WALL TIME FOR CONCCALC:',& 1957 1967 & 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 1958 1972 ! NB: the 'flush' function is possibly a gfortran-specific extension 1959 1973 call flush() … … 1962 1976 end if 1963 1977 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 1964 1989 ! j=mp_pid*nvar_async 1965 1990 ! In the implementation with 3 fields, the processes may have posted 1966 1991 ! MPI_Irecv requests that should be cancelled here 1967 1992 !! TODO: 1968 1969 1970 1971 1972 1973 1974 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 1975 2000 1976 2001 call MPI_FINALIZE(mp_ierr) … … 1981 2006 1982 2007 1983 end subroutine mpif_finalize1984 1985 1986 subroutine get_lun(my_lun)2008 end subroutine mpif_finalize 2009 2010 2011 subroutine get_lun(my_lun) 1987 2012 !*********************************************************************** 1988 2013 ! get_lun: … … 1990 2015 !*********************************************************************** 1991 2016 1992 implicit none1993 1994 integer, intent(inout) :: my_lun1995 integer, save :: free_lun=1001996 logical :: exists, iopen1997 1998 !*********************************************************************** 1999 2000 loop1: do2001 inquire(UNIT=free_lun, EXIST=exists, OPENED=iopen)2002 if (exists .and. .not.iopen) exit loop12003 free_lun = free_lun+12004 end do loop12005 my_lun = free_lun2006 2007 end subroutine get_lun2008 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 none2015 2016 real, intent(in), dimension(:) :: array_in2017 integer, intent(in) :: tstep2018 integer :: lios2019 character(LEN=*), intent(in) :: ident, array_name2020 2021 character(LEN=8) :: c_ts2022 character(LEN=40) :: fn_1, fn_22023 2024 !*********************************************************************** 2025 2026 write(c_ts, FMT='(I8.8,BZ)') tstep2027 fn_1='-'//trim(adjustl(c_ts))//'-'//trim(ident)2028 write(c_ts, FMT='(I2.2,BZ)') mp_np2029 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_in2035 close(UNIT=dat_lun)2036 2037 end subroutine write_data_dbg2017 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 2038 2063 2039 2064
Note: See TracChangeset
for help on using the changeset viewer.