Skip to content

Commit 2ea2def

Browse files
Stop statements (#632)
* METISSE now returns error instead of stopping the code * added back meson.build and .gitignore * updated metisse * removed print statement
1 parent d54bd83 commit 2ea2def

File tree

6 files changed

+51
-16
lines changed

6 files changed

+51
-16
lines changed

src/cosmic/evolve.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -553,14 +553,18 @@ def _evolve_single_system(f):
553553
f["kick_info"],
554554
path_to_tracks,
555555
path_to_he_tracks)
556-
bcm = _evolvebin.binary.bcm[:bcm_index].copy()
557-
bpp = _evolvebin.binary.bpp[:bpp_index].copy()
558-
_evolvebin.binary.bpp[:bpp_index] = np.zeros(bpp.shape)
559-
_evolvebin.binary.bcm[:bcm_index] = np.zeros(bcm.shape)
560-
561-
bpp = np.hstack((bpp, np.ones((bpp.shape[0], 1))*f["bin_num"]))
562-
bcm = np.hstack((bcm, np.ones((bcm.shape[0], 1))*f["bin_num"]))
563-
kick_info = np.hstack((kick_info, np.ones((kick_info.shape[0], 1))*f["bin_num"]))
556+
557+
if bpp_index<0:
558+
raise ValueError("Failed in METISSE_zcnsts")
559+
else:
560+
bcm = _evolvebin.binary.bcm[:bcm_index].copy()
561+
bpp = _evolvebin.binary.bpp[:bpp_index].copy()
562+
_evolvebin.binary.bpp[:bpp_index] = np.zeros(bpp.shape)
563+
_evolvebin.binary.bcm[:bcm_index] = np.zeros(bcm.shape)
564+
565+
bpp = np.hstack((bpp, np.ones((bpp.shape[0], 1))*f["bin_num"]))
566+
bcm = np.hstack((bcm, np.ones((bcm.shape[0], 1))*f["bin_num"]))
567+
kick_info = np.hstack((kick_info, np.ones((kick_info.shape[0], 1))*f["bin_num"]))
564568

565569
return f, bpp, bcm, kick_info, _evolvebin.snvars.natal_kick_array.copy()
566570

src/cosmic/src/assign_commons_COSMIC.f90

+15-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ subroutine assign_commons()
99

1010
real(dp) :: d
1111

12-
1312
if(front_end == COSMIC) then
1413
! use inputs from COSMIC
1514

@@ -25,11 +24,25 @@ subroutine assign_commons()
2524
end subroutine
2625

2726
subroutine get_bhspin(bhspin,id)
28-
use track_support
27+
use track_support, only: tarr,dp
2928
implicit none
3029
integer, intent(in) :: id
3130
real(dp), intent(out) :: bhspin
3231

3332
bhspin = tarr(id)% pars% bhspin
3433
end subroutine
34+
35+
subroutine check_error(err)
36+
use track_support, only: code_error
37+
integer, intent(out) :: err
38+
err = 0
39+
if(code_error) err = 1
40+
end subroutine
41+
42+
43+
subroutine assign_error()
44+
use track_support, only: code_error
45+
code_error = .true.
46+
end subroutine
47+
3548

src/cosmic/src/evolv2.f

+17-2
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ SUBROUTINE evolv2(kstar,mass,tb,ecc,z,tphysf,
218218
*
219219
REAL*8 qc_fixed
220220
LOGICAL switchedCE,disrupt
221+
integer err
221222

222223
Cf2py intent(in) kstar
223224
Cf2py intent(in) mass
@@ -255,8 +256,6 @@ SUBROUTINE evolv2(kstar,mass,tb,ecc,z,tphysf,
255256
endif
256257

257258
if(using_METISSE) CALL initialize_front_end('cosmic')
258-
if(using_METISSE) call allocate_track(2,mass0)
259-
260259
*
261260
* Save the initial state.
262261
*
@@ -340,10 +339,20 @@ SUBROUTINE evolv2(kstar,mass,tb,ecc,z,tphysf,
340339
*
341340
* Set the collision matrix.
342341
*
342+
err = 0
343343
if(using_cmc.eq.0)then
344344
* for SSE path_to_tracks and path_to_he_tracks are empty ('')
345345
CALL zcnsts(z,zpars,path_to_tracks,path_to_he_tracks)
346+
if(using_METISSE) then
347+
call check_error(err)
348+
if (err>0) then
349+
bpp_index_out = -1
350+
return
351+
endif
352+
endif
346353
endif
354+
355+
if(using_METISSE) call allocate_track(2,mass0)
347356
348357
kmin = 1
349358
kmax = 2
@@ -4405,6 +4414,10 @@ SUBROUTINE evolv2(kstar,mass,tb,ecc,z,tphysf,
44054414
evolve_type = 10.0
44064415
!added by PA for systems that stop evolving halfway
44074416
if(iter.ge.loop) evolve_type = 100.0
4417+
if (using_METISSE) then
4418+
call check_error(err)
4419+
if (err>0) evolve_type = 101.0
4420+
end if
44084421
rrl1 = rad(1)/rol(1)
44094422
rrl2 = rad(2)/rol(2)
44104423
teff1 = 1000.d0*((1130.d0*lumin(1)/
@@ -4537,6 +4550,7 @@ SUBROUTINE evolv2(kstar,mass,tb,ecc,z,tphysf,
45374550
* CALL exit(0)
45384551
* STOP
45394552
endif
4553+
45404554
bcm(ip+1,1) = -1.0
45414555
bpp(jp+1,1) = -1.0
45424556
@@ -4546,6 +4560,7 @@ SUBROUTINE evolv2(kstar,mass,tb,ecc,z,tphysf,
45464560
kick_info_out = kick_info
45474561
endif
45484562
if (using_METISSE) call dealloc_track()
4563+
45494564
*
45504565
45514566
END SUBROUTINE evolv2

src/cosmic/src/zcnsts.f

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ SUBROUTINE zcnsts(z,zpars,path_to_tracks,path_to_he_tracks)
44

55
real*8 z,zpars(20)
66
CHARACTER*256 path_to_tracks,path_to_he_tracks
7-
7+
integer :: ierr
88

99
if (using_METISSE) then
1010
!WRITE(*,*) 'Calling METISSE_zcnsts',using_METISSE
11-
CALL METISSE_zcnsts(z,zpars,path_to_tracks,path_to_he_tracks)
11+
CALL METISSE_zcnsts(z,zpars,path_to_tracks,
12+
& path_to_he_tracks,ierr)
13+
if (ierr/=0) call assign_error()
1214

1315
elseif (using_SSE) then
1416
!WRITE(*,*) 'Calling SSE_zcnsts'

src/cosmic/utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1716,7 +1716,8 @@ def convert_kstar_evol_type(bpp):
17161716
14: "blue straggler",
17171717
15: "supernova of primary",
17181718
16: "supernova of secondary",
1719-
100: "RLOF interpolation timeout error"
1719+
100: "RLOF interpolation timeout error",
1720+
101: "METISSE error"
17201721
}
17211722

17221723
evolve_type_string_to_int_dict = {

0 commit comments

Comments
 (0)