From f0744543fc607cb7e1a78269dc185ecf20b4be10 Mon Sep 17 00:00:00 2001 From: David A Minton Date: Fri, 30 Jul 2021 17:00:37 -0400 Subject: [PATCH 1/5] Switched to ifort flags --- Makefile.Defines | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile.Defines b/Makefile.Defines index 70069bb71..291f2c604 100644 --- a/Makefile.Defines +++ b/Makefile.Defines @@ -65,13 +65,13 @@ GPAR = -fopenmp -ftree-parallelize-loops=4 GMEM = -fsanitize=undefined -fsanitize=address -fsanitize=leak GWARNINGS = -Wall -Warray-bounds -Wimplicit-interface -Wextra -Warray-temporaries -#FFLAGS = $(IDEBUG) $(HEAPARR) +FFLAGS = $(IDEBUG) $(HEAPARR) #FFLAGS = -init=snan,arrays -no-wrap-margin -O3 $(STRICTREAL) $(SIMDVEC) $(PAR) -#FORTRAN = ifort +FORTRAN = ifort #AR = xiar -FORTRAN = gfortran -FFLAGS = -ffree-line-length-none $(GDEBUG) $(GMEM) +#FORTRAN = gfortran +#FFLAGS = -ffree-line-length-none $(GDEBUG) $(GMEM) AR = ar # DO NOT include in CFLAGS the "-c" option to compile object only From 472e1fee71ea1afd6cff195d56384a15636d85f7 Mon Sep 17 00:00:00 2001 From: David A Minton Date: Fri, 30 Jul 2021 17:21:15 -0400 Subject: [PATCH 2/5] Fixed concurrent loop issue when there is nothing that meets the criteria for checking encounters --- .../1pl_1pl_encounter/swiftest_vs_swifter.ipynb | 2 +- src/symba/symba_encounter_check.f90 | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/symba_swifter_comparison/1pl_1pl_encounter/swiftest_vs_swifter.ipynb b/examples/symba_swifter_comparison/1pl_1pl_encounter/swiftest_vs_swifter.ipynb index dc1a9992f..57dd1934a 100644 --- a/examples/symba_swifter_comparison/1pl_1pl_encounter/swiftest_vs_swifter.ipynb +++ b/examples/symba_swifter_comparison/1pl_1pl_encounter/swiftest_vs_swifter.ipynb @@ -43,7 +43,7 @@ "output_type": "stream", "text": [ "Reading Swiftest file param.swiftest.in\n", - "Reading in time 6.845e-04\n", + "Reading in time 1.506e-01\n", "Creating Dataset\n" ] }, diff --git a/src/symba/symba_encounter_check.f90 b/src/symba/symba_encounter_check.f90 index 1a9d8c68f..baa2dc5f5 100644 --- a/src/symba/symba_encounter_check.f90 +++ b/src/symba/symba_encounter_check.f90 @@ -75,6 +75,7 @@ module function symba_encounter_check_pltpenc(self, system, dt, irec) result(lan real(DP), dimension(NDIM) :: xr, vr logical :: lencounter, isplpl real(DP) :: rlim2, rji2 + logical, dimension(:), allocatable :: lencmask lany_encounter = .false. if (self%nenc == 0) return @@ -90,7 +91,10 @@ module function symba_encounter_check_pltpenc(self, system, dt, irec) result(lan class is (symba_pl) select type(tp => system%tp) class is (symba_tp) - do concurrent(i = 1:self%nenc, self%status(i) == ACTIVE .and. self%level(i) == irec - 1) + allocate(lencmask(self%nenc)) + lencmask(:) = (self%status(1:self%nenc) == ACTIVE) .and. (self%level(:) == irec - 1) + if (.not.any(lencmask(:))) return + do concurrent(i = 1:self%nenc, lencmask(i)) associate(index_i => self%index1(i), index_j => self%index2(i)) if (isplpl) then xr(:) = pl%xh(:,index_j) - pl%xh(:,index_i) From 445a8cc3d36060f21f5a7c643d77209f1620858c Mon Sep 17 00:00:00 2001 From: David A Minton Date: Fri, 30 Jul 2021 17:26:36 -0400 Subject: [PATCH 3/5] Rearranged encounter check loop --- src/symba/symba_encounter_check.f90 | 42 ++++++++++++++--------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/symba/symba_encounter_check.f90 b/src/symba/symba_encounter_check.f90 index baa2dc5f5..c65981beb 100644 --- a/src/symba/symba_encounter_check.f90 +++ b/src/symba/symba_encounter_check.f90 @@ -71,7 +71,7 @@ module function symba_encounter_check_pltpenc(self, system, dt, irec) result(lan integer(I4B), intent(in) :: irec !! Current recursion level logical :: lany_encounter !! Returns true if there is at least one close encounter ! Internals - integer(I4B) :: i + integer(I4B) :: k real(DP), dimension(NDIM) :: xr, vr logical :: lencounter, isplpl real(DP) :: rlim2, rji2 @@ -93,41 +93,41 @@ module function symba_encounter_check_pltpenc(self, system, dt, irec) result(lan class is (symba_tp) allocate(lencmask(self%nenc)) lencmask(:) = (self%status(1:self%nenc) == ACTIVE) .and. (self%level(:) == irec - 1) - if (.not.any(lencmask(:))) return - do concurrent(i = 1:self%nenc, lencmask(i)) - associate(index_i => self%index1(i), index_j => self%index2(i)) + if (.not.any(lencmask(:))) return + associate(ind1 => self%index1, ind2 => self%index2) + do concurrent(k = 1:self%nenc, lencmask(k)) if (isplpl) then - xr(:) = pl%xh(:,index_j) - pl%xh(:,index_i) - vr(:) = pl%vb(:,index_j) - pl%vb(:,index_i) - call symba_encounter_check_one(xr(1), xr(2), xr(3), vr(1), vr(2), vr(3), pl%rhill(index_i), pl%rhill(index_j), dt, irec, lencounter, self%lvdotr(i)) + xr(:) = pl%xh(:,ind2(k)) - pl%xh(:,ind1(k)) + vr(:) = pl%vb(:,ind2(k)) - pl%vb(:,ind1(k)) + call symba_encounter_check_one(xr(1), xr(2), xr(3), vr(1), vr(2), vr(3), pl%rhill(ind1(k)), pl%rhill(ind2(k)), dt, irec, lencounter, self%lvdotr(k)) else - xr(:) = tp%xh(:,index_j) - pl%xh(:,index_i) - vr(:) = tp%vb(:,index_j) - pl%vb(:,index_i) - call symba_encounter_check_one(xr(1), xr(2), xr(3), vr(1), vr(2), vr(3), pl%rhill(index_i), 0.0_DP, dt, irec, lencounter, self%lvdotr(i)) + xr(:) = tp%xh(:,ind2(k)) - pl%xh(:,ind1(k)) + vr(:) = tp%vb(:,ind2(k)) - pl%vb(:,ind1(k)) + call symba_encounter_check_one(xr(1), xr(2), xr(3), vr(1), vr(2), vr(3), pl%rhill(ind1(k)), 0.0_DP, dt, irec, lencounter, self%lvdotr(k)) end if if (lencounter) then if (isplpl) then - rlim2 = (pl%radius(index_i) + pl%radius(index_j))**2 + rlim2 = (pl%radius(ind1(k)) + pl%radius(ind2(k)))**2 else - rlim2 = (pl%radius(index_i))**2 + rlim2 = (pl%radius(ind1(k)))**2 end if rji2 = dot_product(xr(:), xr(:))! Check to see if these are physically overlapping bodies first, which we should ignore if (rji2 > rlim2) then lany_encounter = .true. - pl%levelg(index_i) = irec - pl%levelm(index_i) = MAX(irec, pl%levelm(index_i)) + pl%levelg(ind1(k)) = irec + pl%levelm(ind1(k)) = MAX(irec, pl%levelm(ind1(k))) if (isplpl) then - pl%levelg(index_j) = irec - pl%levelm(index_j) = MAX(irec, pl%levelm(index_j)) + pl%levelg(ind2(k)) = irec + pl%levelm(ind2(k)) = MAX(irec, pl%levelm(ind2(k))) else - tp%levelg(index_j) = irec - tp%levelm(index_j) = MAX(irec, tp%levelm(index_j)) + tp%levelg(ind2(k)) = irec + tp%levelm(ind2(k)) = MAX(irec, tp%levelm(ind2(k))) end if - self%level(i) = irec + self%level(k) = irec end if end if - end associate - end do + end do + end associate end select end select From c2ca5ce6fd20093758aabcc4be6345a27f325128 Mon Sep 17 00:00:00 2001 From: David A Minton Date: Fri, 30 Jul 2021 17:28:00 -0400 Subject: [PATCH 4/5] Fixed index range --- src/symba/symba_encounter_check.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/symba/symba_encounter_check.f90 b/src/symba/symba_encounter_check.f90 index c65981beb..808ee2347 100644 --- a/src/symba/symba_encounter_check.f90 +++ b/src/symba/symba_encounter_check.f90 @@ -92,7 +92,7 @@ module function symba_encounter_check_pltpenc(self, system, dt, irec) result(lan select type(tp => system%tp) class is (symba_tp) allocate(lencmask(self%nenc)) - lencmask(:) = (self%status(1:self%nenc) == ACTIVE) .and. (self%level(:) == irec - 1) + lencmask(:) = (self%status(1:self%nenc) == ACTIVE) .and. (self%level(1:self%nenc) == irec - 1) if (.not.any(lencmask(:))) return associate(ind1 => self%index1, ind2 => self%index2) do concurrent(k = 1:self%nenc, lencmask(k)) From 8f771a134fafc0def1050f7a19b0418981da7f24 Mon Sep 17 00:00:00 2001 From: David Minton Date: Fri, 30 Jul 2021 22:59:20 -0400 Subject: [PATCH 5/5] Fixed plid in example --- .../1pl_1pl_encounter/cb.swiftest.in | Bin 80 -> 53 bytes .../1pl_1pl_encounter/init_cond.py | 2 +- .../1pl_1pl_encounter/param.swiftest.in | 2 +- .../1pl_1pl_encounter/pl.swifter.in | 2 +- .../1pl_1pl_encounter/pl.swiftest.in | Bin 248 -> 228 bytes .../1pl_1pl_encounter/tp.swiftest.in | Bin 16 -> 2 bytes .../tests/bin2xr/swiftest/bin2xr_swiftest.py | 5 +- .../tests/bin2xr/swiftest/param.swiftest.in | 62 +++++++++--------- .../tests/bin2xr/swiftest/pl.swiftest.in | Bin 1088 -> 256 bytes .../tests/bin2xr/swiftest/tp.swiftest.in | Bin 125 -> 16 bytes 10 files changed, 36 insertions(+), 37 deletions(-) diff --git a/examples/symba_swifter_comparison/1pl_1pl_encounter/cb.swiftest.in b/examples/symba_swifter_comparison/1pl_1pl_encounter/cb.swiftest.in index d0ae0ed15fe3ea8dd15557055a926fce3c60b59c..4c5d870405c9daad1d597cb1d3f2bd78a1b2227e 100644 GIT binary patch literal 53 wcmW;Axe)*$3rbo3*74~+Eq5}gct*a?m%+)WyI1?iYw*UYD literal 80 ncmd;JKmZOP6NHU2HoW29>+AsI-}OJ>6US3*597mhVB-S-U7iOf diff --git a/examples/symba_swifter_comparison/1pl_1pl_encounter/init_cond.py b/examples/symba_swifter_comparison/1pl_1pl_encounter/init_cond.py index f63022624..7600320c2 100755 --- a/examples/symba_swifter_comparison/1pl_1pl_encounter/init_cond.py +++ b/examples/symba_swifter_comparison/1pl_1pl_encounter/init_cond.py @@ -132,7 +132,7 @@ plfile = FortranFile(swiftest_pl, 'w') plfile.write_record(npl) -plfile.write_record(plid1) +plfile.write_record(np.array([plid1, plid2])) plfile.write_record(np.vstack([p_pl1[0],p_pl2[0]])) plfile.write_record(np.vstack([p_pl1[1],p_pl2[1]])) plfile.write_record(np.vstack([p_pl1[2],p_pl2[2]])) diff --git a/examples/symba_swifter_comparison/1pl_1pl_encounter/param.swiftest.in b/examples/symba_swifter_comparison/1pl_1pl_encounter/param.swiftest.in index a7f91ba33..1866557b2 100644 --- a/examples/symba_swifter_comparison/1pl_1pl_encounter/param.swiftest.in +++ b/examples/symba_swifter_comparison/1pl_1pl_encounter/param.swiftest.in @@ -5,7 +5,7 @@ DT 0.0006844626967830253 CB_IN cb.swiftest.in PL_IN pl.swiftest.in TP_IN tp.swiftest.in -IN_TYPE REAL8 +IN_TYPE ASCII ISTEP_OUT 1 ISTEP_DUMP 1 BIN_OUT bin.swiftest.dat diff --git a/examples/symba_swifter_comparison/1pl_1pl_encounter/pl.swifter.in b/examples/symba_swifter_comparison/1pl_1pl_encounter/pl.swifter.in index 9f0548fc1..0eb21018b 100644 --- a/examples/symba_swifter_comparison/1pl_1pl_encounter/pl.swifter.in +++ b/examples/symba_swifter_comparison/1pl_1pl_encounter/pl.swifter.in @@ -1,5 +1,5 @@ 3 ! Planet input file generated using init_cond.py -1 39.476926408897625196 +1 39.47692640889762629 0.0 0.0 0.0 0.0 0.0 0.0 2 0.00012002693582795244940133 0.010044724833237892 diff --git a/examples/symba_swifter_comparison/1pl_1pl_encounter/pl.swiftest.in b/examples/symba_swifter_comparison/1pl_1pl_encounter/pl.swiftest.in index 51f9195316f75ec269d86d78c9046aaa2d16dab0..19c6d6e3a2436162bb5984e0ecb1cb9352cb223f 100644 GIT binary patch literal 228 zcmZ9Gxe)^~30`5m% zX0lVQ37Yye{^|yd{X~mu+c^*|K`` Ygvg?I8#T=l^4}PjYzRwv=DU9V0CM9iPyhe` literal 248 zcmd;JU|?VZVi4efVr0GmSO!FVu-A;~KlD}OgFQ$LAr4mn79&SoLf0kax1yv&qwR7r zUM5KgLgq{PMDyJ*lehmPxLQ_Dd5axP{puz5sv(nF?6>HD&rRBu2zRHD`Gi8o5H|Z` N5_L__Z6AZx0{}Ng9lHPk diff --git a/examples/symba_swifter_comparison/1pl_1pl_encounter/tp.swiftest.in b/examples/symba_swifter_comparison/1pl_1pl_encounter/tp.swiftest.in index 64bf92f74a457d2f4bc42798493db15cc3ab1008..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 100644 GIT binary patch literal 2 JcmXru0ssJP06PEx literal 16 Ncmd;JKmZOP6953P01*HH diff --git a/python/swiftest/tests/bin2xr/swiftest/bin2xr_swiftest.py b/python/swiftest/tests/bin2xr/swiftest/bin2xr_swiftest.py index 9a377876a..0a430c654 100644 --- a/python/swiftest/tests/bin2xr/swiftest/bin2xr_swiftest.py +++ b/python/swiftest/tests/bin2xr/swiftest/bin2xr_swiftest.py @@ -1,5 +1,4 @@ import swiftest -import swiftest.io as swio -param_file = "param.swiftest.in" sim = swiftest.Simulation(param_file="param.swiftest.in") -ds = swio.swiftest2xr(sim.param) \ No newline at end of file +sim.bin2xr() +sim.ds \ No newline at end of file diff --git a/python/swiftest/tests/bin2xr/swiftest/param.swiftest.in b/python/swiftest/tests/bin2xr/swiftest/param.swiftest.in index 6a9e599f9..a7f91ba33 100644 --- a/python/swiftest/tests/bin2xr/swiftest/param.swiftest.in +++ b/python/swiftest/tests/bin2xr/swiftest/param.swiftest.in @@ -1,31 +1,31 @@ -! VERSION Swiftest parameter file converted from Swift -BIG_DISCARD NO -BIN_OUT bin.dat -CB_IN cb.swiftest.in -CHK_CLOSE YES -CHK_QMIN 0.00468 -CHK_QMIN_COORD HELIO -CHK_QMIN_RANGE 4.68e-03 100.0 -CHK_RMAX 100.0 -CHK_RMIN 0.00468 -DT 5.0 -DU2M 149597870700.0 -ENC_OUT enc.dat -ENERGY NO -EXTRA_FORCE NO -FRAGMENTATION NO -GR NO -ISTEP_DUMP 7305000 -ISTEP_OUT 7305000 -MU2KG 1.988409870698051e+30 -OUT_FORM EL -OUT_STAT UNKNOWN -PL_IN pl.swiftest.in -ROTATION NO -T0 0.0 -TIDES NO -TP_IN tp.swiftest.in -TSTOP 365250000000.0 -TU2S 86400 -YARKOVSKY NO -YORP NO +! Swiftest input file generated using init_cond.py +T0 0 +TSTOP 0.15 +DT 0.0006844626967830253 +CB_IN cb.swiftest.in +PL_IN pl.swiftest.in +TP_IN tp.swiftest.in +IN_TYPE REAL8 +ISTEP_OUT 1 +ISTEP_DUMP 1 +BIN_OUT bin.swiftest.dat +OUT_TYPE REAL8 +OUT_FORM XV +OUT_STAT REPLACE +CHK_CLOSE yes +CHK_RMIN 0.004650467260962157 +CHK_RMAX 1000.0 +CHK_EJECT 1000.0 +CHK_QMIN 0.004650467260962157 +CHK_QMIN_COORD HELIO +CHK_QMIN_RANGE 0.004650467260962157 1000.0 +ENC_OUT enc.swiftest.dat +EXTRA_FORCE no +BIG_DISCARD no +ROTATION no +GR no +MU2KG 1.988409870698051e+30 +DU2M 149597870700.0 +TU2S 31557600.0 +RHILL_PRESENT yes +MTINY 1e-12 diff --git a/python/swiftest/tests/bin2xr/swiftest/pl.swiftest.in b/python/swiftest/tests/bin2xr/swiftest/pl.swiftest.in index b7814ac98f87d48e50fd91844e705b4b7a167c93..d8da7a92a44b1e9caa3907ead959cdec31e066cc 100644 GIT binary patch literal 256 zcmd;JU|?VZVi4c}VgVqA@l!y8KmZa0VF>tOuNl*S=&QyDdsK0lJi2<~#U*rILVhbs zIyBlY7vp7;bRcBDlutC@{W5v`KZ2`e<&?MB!PKu_Vy_x9sl|Sa{`cIZU5Rja3YkwR SWDH@mKPFMv^xXC_SUmurogOa$ literal 1088 zcmXw&%dz7?2u1gbLJ3&K{}a&UpTeA${WdO{YT$A%^ksKEtCrD`|30dhKIJk#ZT~)! z*GC==X&dR?3W>;@ScI?0W_Ojl?TLxGM`muTE8l*dm}<+;SkB1I*85V3^>&8Ow2b_s zmS*FWRqA)<<##_8RJB;t$rX=8qQT}*UF#s&v{oE}KP8spBPyA#WqG3{P@)s+U1L#t z)QO~ex^?ziG0rbtTuOsX^Bu9TW`eC?QlXtp>=pMsyDh5zC(p{$++g{GSCa{~*_E*} zlx$6xS57tI(EFp0Cek(lY#!ER*Fi7Z=E5A&%ocz2Tolbd=B20jZBO8#F$cqx=%F)L z-uq;1daAzO+G8zH|H;z_6Dc886p{K3&wSgafx#a2wT2IcC%^C4eBm{+tW`~M)7Xro zm`TcZ3cs_mPYhsSLK@ggKwDR#8T~WrXzg#k=mrSZ9iLBgkw&aWJI@!V5^i+Dfa8fW zDX<%3jw}8mV?oNvV1alJyjKDA3YW(%;H%4G<$37Ndaq4?9cvtA!FKfg|BXqzsjBU( zo)G+uX1~A_bJvqK(9_7l`SPR7i<9b^#BmsWt(34;g%rF8!13zxSxpXLlx=X*UtCJZ zE@0>i8GX&I59zVzDu1##tYLl2E{!LgRfYn0niZ^+Kkf7$TUllLqYK_@6KDUpOM9Uk jZM+vnFw-xasX@?w;s(!88)XStCM7FmK{Q=Mo%=r**G~~CO8#k)xIAbWog)* mw4%gy*{=&~ZwoOMx-ra$h;ABL&fIbCZY-=O<8Jjn$n^pDZy1IE