diff --git a/tardis/montecarlo/src/cmontecarlo.c b/tardis/montecarlo/src/cmontecarlo.c index 6fae05d0efa..dbb7f0041fa 100644 --- a/tardis/montecarlo/src/cmontecarlo.c +++ b/tardis/montecarlo/src/cmontecarlo.c @@ -1,12 +1,16 @@ -#define _POSIX_C_SOURCE 1 #include +#include +#include +#include #ifdef WITHOPENMP #include #endif +#include "io.h" #include "abbrev.h" +#include "status.h" +#include "rpacket.h" #include "cmontecarlo.h" -#include "io.h" /** Look for a place to insert a value in an inversely sorted float array. @@ -18,7 +22,7 @@ * * @return index of the next boundary to the left */ -static tardis_error_t +tardis_error_t reverse_binary_search (const double *x, double x_insert, int64_t imin, int64_t imax, int64_t * result) { @@ -59,6 +63,14 @@ reverse_binary_search (const double *x, double x_insert, return ret_val; } +/** Insert a value in to an array of line frequencies + * + * @param nu array of line frequencies + * @param nu_insert value of nu key + * @param number_of_lines number of lines in the line list + * + * @return index of the next line ot the red. If the key value is redder than the reddest line returns number_of_lines. + */ tardis_error_t line_search (const double *nu, double nu_insert, int64_t number_of_lines, int64_t * result) diff --git a/tardis/montecarlo/src/cmontecarlo.h b/tardis/montecarlo/src/cmontecarlo.h index 8f2b5676671..014c4558a0c 100644 --- a/tardis/montecarlo/src/cmontecarlo.h +++ b/tardis/montecarlo/src/cmontecarlo.h @@ -1,16 +1,11 @@ #ifndef TARDIS_CMONTECARLO_H #define TARDIS_CMONTECARLO_H -#include -#include #include -#include -#include -#include #include "randomkit/randomkit.h" #include "rpacket.h" #include "status.h" -#include "cmontecarlo1.h" +#include "storage.h" #ifdef WITH_VPACKET_LOGGING #define LOG_VPACKETS 1 @@ -18,12 +13,19 @@ #define LOG_VPACKETS 0 #endif -typedef void (*montecarlo_event_handler_t) (rpacket_t * packet, - storage_model_t * storage, +typedef void (*montecarlo_event_handler_t) (rpacket_t *packet, + storage_model_t *storage, double distance, rk_state *mt_state); void initialize_random_kit (unsigned long seed); +tardis_error_t line_search (const double *nu, double nu_insert, + int64_t number_of_lines, int64_t * result); + +tardis_error_t +reverse_binary_search (const double *x, double x_insert, + int64_t imin, int64_t imax, int64_t * result); + double rpacket_doppler_factor(const rpacket_t *packet, const storage_model_t *storage); /** Calculate the distance to shell boundary. @@ -54,7 +56,7 @@ tardis_error_t compute_distance2line (rpacket_t * packet, * * sets distance to the next continuum event (in centimeters) in packet rpacket structure */ -void compute_distance2continuum (rpacket_t * packet, storage_model_t * storage); +void compute_distance2continuum (rpacket_t *packet, storage_model_t *storage); int64_t macro_atom (const rpacket_t * packet, const storage_model_t * storage, rk_state *mt_state); diff --git a/tardis/montecarlo/src/cmontecarlo1.h b/tardis/montecarlo/src/cmontecarlo1.h deleted file mode 100644 index be027c81c53..00000000000 --- a/tardis/montecarlo/src/cmontecarlo1.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef TARDIS_CMONTECARLO1_H -#define TARDIS_CMONTECARLO1_H - -/** Insert a value in to an array of line frequencies - * - * @param nu array of line frequencies - * @param nu_insert value of nu key - * @param number_of_lines number of lines in the line list - * - * @return index of the next line ot the red. If the key value is redder than the reddest line returns number_of_lines. - */ -tardis_error_t line_search (const double *nu, double nu_insert, - int64_t number_of_lines, int64_t * result); - -#endif diff --git a/tardis/montecarlo/src/io.h b/tardis/montecarlo/src/io.h index 11de95aac55..e2c3dc7054b 100644 --- a/tardis/montecarlo/src/io.h +++ b/tardis/montecarlo/src/io.h @@ -1,6 +1,8 @@ +#define _POSIX_C_SOURCE 1 + +#include #include #include -#include #define STATUS_FORMAT "\r\033[2K\t[%" PRId64 "%%] Packets(finished/total): %" PRId64 "/%" PRId64 diff --git a/tardis/montecarlo/src/rpacket.c b/tardis/montecarlo/src/rpacket.c index f80432af377..f342f48cbcf 100644 --- a/tardis/montecarlo/src/rpacket.c +++ b/tardis/montecarlo/src/rpacket.c @@ -1,6 +1,11 @@ +#include +#include #include "rpacket.h" #include "storage.h" +extern tardis_error_t line_search (const double *nu, double nu_insert, + int64_t number_of_lines, int64_t * result); + tardis_error_t rpacket_init (rpacket_t * packet, storage_model_t * storage, int packet_index, int virtual_packet_flag) diff --git a/tardis/montecarlo/src/rpacket.h b/tardis/montecarlo/src/rpacket.h index 5434db8ec20..2f5d654e8f0 100644 --- a/tardis/montecarlo/src/rpacket.h +++ b/tardis/montecarlo/src/rpacket.h @@ -1,16 +1,12 @@ #ifndef TARDIS_RPACKET_H #define TARDIS_RPACKET_H -#include +#include #include #include -#include -#include -#include #include "randomkit/randomkit.h" #include "status.h" #include "storage.h" -#include "cmontecarlo1.h" #define MISS_DISTANCE 1e99 #define C 29979245800.0 diff --git a/tardis/montecarlo/src/storage.h b/tardis/montecarlo/src/storage.h index 0ca31a049d4..2abea5b1f2b 100644 --- a/tardis/montecarlo/src/storage.h +++ b/tardis/montecarlo/src/storage.h @@ -1,12 +1,9 @@ #ifndef TARDIS_STORAGE_H #define TARDIS_STORAGE_H -#include -#include #include -#include -#include -#include + +#include "status.h" typedef struct StorageModel {