diff --git a/src/cosmic/evolve.py b/src/cosmic/evolve.py index 14fce405f..6fade993b 100644 --- a/src/cosmic/evolve.py +++ b/src/cosmic/evolve.py @@ -553,14 +553,18 @@ def _evolve_single_system(f): f["kick_info"], path_to_tracks, path_to_he_tracks) - bcm = _evolvebin.binary.bcm[:bcm_index].copy() - bpp = _evolvebin.binary.bpp[:bpp_index].copy() - _evolvebin.binary.bpp[:bpp_index] = np.zeros(bpp.shape) - _evolvebin.binary.bcm[:bcm_index] = np.zeros(bcm.shape) - - bpp = np.hstack((bpp, np.ones((bpp.shape[0], 1))*f["bin_num"])) - bcm = np.hstack((bcm, np.ones((bcm.shape[0], 1))*f["bin_num"])) - kick_info = np.hstack((kick_info, np.ones((kick_info.shape[0], 1))*f["bin_num"])) + + if bpp_index<0: + raise ValueError("Failed in METISSE_zcnsts") + else: + bcm = _evolvebin.binary.bcm[:bcm_index].copy() + bpp = _evolvebin.binary.bpp[:bpp_index].copy() + _evolvebin.binary.bpp[:bpp_index] = np.zeros(bpp.shape) + _evolvebin.binary.bcm[:bcm_index] = np.zeros(bcm.shape) + + bpp = np.hstack((bpp, np.ones((bpp.shape[0], 1))*f["bin_num"])) + bcm = np.hstack((bcm, np.ones((bcm.shape[0], 1))*f["bin_num"])) + kick_info = np.hstack((kick_info, np.ones((kick_info.shape[0], 1))*f["bin_num"])) return f, bpp, bcm, kick_info, _evolvebin.snvars.natal_kick_array.copy() diff --git a/src/cosmic/src/METISSE b/src/cosmic/src/METISSE index e6798b953..d08997883 160000 --- a/src/cosmic/src/METISSE +++ b/src/cosmic/src/METISSE @@ -1 +1 @@ -Subproject commit e6798b953a8beda86e2ea640b94aeb051f55ffbc +Subproject commit d08997883d42e3b3f89f139f97c497cf2b9c1447 diff --git a/src/cosmic/src/assign_commons_COSMIC.f90 b/src/cosmic/src/assign_commons_COSMIC.f90 index 5d00046fa..cb3c33093 100644 --- a/src/cosmic/src/assign_commons_COSMIC.f90 +++ b/src/cosmic/src/assign_commons_COSMIC.f90 @@ -9,7 +9,6 @@ subroutine assign_commons() real(dp) :: d - if(front_end == COSMIC) then ! use inputs from COSMIC @@ -25,11 +24,25 @@ subroutine assign_commons() end subroutine subroutine get_bhspin(bhspin,id) - use track_support + use track_support, only: tarr,dp implicit none integer, intent(in) :: id real(dp), intent(out) :: bhspin bhspin = tarr(id)% pars% bhspin end subroutine + + subroutine check_error(err) + use track_support, only: code_error + integer, intent(out) :: err + err = 0 + if(code_error) err = 1 + end subroutine + + + subroutine assign_error() + use track_support, only: code_error + code_error = .true. + end subroutine + diff --git a/src/cosmic/src/evolv2.f b/src/cosmic/src/evolv2.f index 4fcf647ec..e6ef134a4 100644 --- a/src/cosmic/src/evolv2.f +++ b/src/cosmic/src/evolv2.f @@ -218,6 +218,7 @@ SUBROUTINE evolv2(kstar,mass,tb,ecc,z,tphysf, * REAL*8 qc_fixed LOGICAL switchedCE,disrupt + integer err Cf2py intent(in) kstar Cf2py intent(in) mass @@ -255,8 +256,6 @@ SUBROUTINE evolv2(kstar,mass,tb,ecc,z,tphysf, endif if(using_METISSE) CALL initialize_front_end('cosmic') - if(using_METISSE) call allocate_track(2,mass0) - * * Save the initial state. * @@ -340,10 +339,20 @@ SUBROUTINE evolv2(kstar,mass,tb,ecc,z,tphysf, * * Set the collision matrix. * + err = 0 if(using_cmc.eq.0)then * for SSE path_to_tracks and path_to_he_tracks are empty ('') CALL zcnsts(z,zpars,path_to_tracks,path_to_he_tracks) + if(using_METISSE) then + call check_error(err) + if (err>0) then + bpp_index_out = -1 + return + endif + endif endif + + if(using_METISSE) call allocate_track(2,mass0) kmin = 1 kmax = 2 @@ -4405,6 +4414,10 @@ SUBROUTINE evolv2(kstar,mass,tb,ecc,z,tphysf, evolve_type = 10.0 !added by PA for systems that stop evolving halfway if(iter.ge.loop) evolve_type = 100.0 + if (using_METISSE) then + call check_error(err) + if (err>0) evolve_type = 101.0 + end if rrl1 = rad(1)/rol(1) rrl2 = rad(2)/rol(2) teff1 = 1000.d0*((1130.d0*lumin(1)/ @@ -4537,6 +4550,7 @@ SUBROUTINE evolv2(kstar,mass,tb,ecc,z,tphysf, * CALL exit(0) * STOP endif + bcm(ip+1,1) = -1.0 bpp(jp+1,1) = -1.0 @@ -4546,6 +4560,7 @@ SUBROUTINE evolv2(kstar,mass,tb,ecc,z,tphysf, kick_info_out = kick_info endif if (using_METISSE) call dealloc_track() + * END SUBROUTINE evolv2 diff --git a/src/cosmic/src/zcnsts.f b/src/cosmic/src/zcnsts.f index 40bd3af6b..aab51271a 100644 --- a/src/cosmic/src/zcnsts.f +++ b/src/cosmic/src/zcnsts.f @@ -4,11 +4,13 @@ SUBROUTINE zcnsts(z,zpars,path_to_tracks,path_to_he_tracks) real*8 z,zpars(20) CHARACTER*256 path_to_tracks,path_to_he_tracks - + integer :: ierr if (using_METISSE) then !WRITE(*,*) 'Calling METISSE_zcnsts',using_METISSE - CALL METISSE_zcnsts(z,zpars,path_to_tracks,path_to_he_tracks) + CALL METISSE_zcnsts(z,zpars,path_to_tracks, + & path_to_he_tracks,ierr) + if (ierr/=0) call assign_error() elseif (using_SSE) then !WRITE(*,*) 'Calling SSE_zcnsts' diff --git a/src/cosmic/utils.py b/src/cosmic/utils.py index 6db35a5b1..f44eaad86 100644 --- a/src/cosmic/utils.py +++ b/src/cosmic/utils.py @@ -1716,7 +1716,8 @@ def convert_kstar_evol_type(bpp): 14: "blue straggler", 15: "supernova of primary", 16: "supernova of secondary", - 100: "RLOF interpolation timeout error" + 100: "RLOF interpolation timeout error", + 101: "METISSE error" } evolve_type_string_to_int_dict = {