Miscellaneous Functions Fortran Subroutines

Description

This module provides the Fortran code for the handling of various miscellaneous functions, not tied to one specific sub-section of the codebase.

Quick access

Routines:

calc_j0(), distribute_objects_in_circle(), find_nearest_point(), get_circle_area_overlap(), get_random_seed_size(), haversine_wrapper()

Variables

  • misc_functions_fortran/dp [integer,parameter=kind(0.0d0)]
  • misc_functions_fortran/pi [real,parameter=4.0_dp*atan(1.0_dp)]

Subroutines and functions

subroutine  misc_functions_fortran/haversine_wrapper(lon1, lon2, lat1, lat2, hav_dist)

Wrapper for the haversine formula in shared_library.f90.

Parameters:
  • lon1 [real,in]

  • lon2 [real,in]

  • lat1 [real,in]

  • lat2 [real,in]

  • hav_dist [real,out]

Call to:

haversine()

subroutine  misc_functions_fortran/find_nearest_point(source_lon, source_lat, point_lon, point_lat, point_ind)

Find the nearest on-sky distance between a series of coordinates and another list of positions.

Parameters:
  • source_lon (*) [real,in]

  • source_lat (*) [real,in]

  • point_lon (*) [real,in]

  • point_lat (*) [real,in]

  • point_ind (size(source_lon) [integer,out] :: pre-convert one-index fortran to zero-index python indices

Call to:

haversine()

subroutine  misc_functions_fortran/calc_j0(r, r0, j0s)

Wrapper for jy01a_j0, to calculate the Bessel Function of First Kind of Zeroth Order for arrays of rs and rhos.

Parameters:
  • r (*) [real,in]

  • r0 (*) [real,in]

  • j0s (size(r,size(r0) [real,out]

Call to:

jy01a_j0()

subroutine  misc_functions_fortran/get_circle_area_overlap(cat_ax1, cat_ax2, density_radius, hull_ax1, hull_ax2, seed, circ_overlap_area)

Calculates the amount of circle overlap with a rectangle of particular coordinates. Adapts code provided by B. Retter, from Retter, Hatchell & Naylor (2019, MNRAS, 487, 887).

Parameters:
  • cat_ax1 (*) [real,in]

  • cat_ax2 (*) [real,in]

  • density_radius [real,in]

  • hull_ax1 (*) [real,in]

  • hull_ax2 (*) [real,in]

  • seed (,) [integer,in]

  • circ_overlap_area (size(cat_ax1) [real,out]

Call to:

haversine(), distribute_objects_in_circle()

subroutine  misc_functions_fortran/distribute_objects_in_circle(x0, y0, r, t, x0s, y0s)

Distribute objects around x0, y0, such that they are a great-circle distance r from the central coordinate by an angle t.

Parameters:
  • x0 [real,in]

  • y0 [real,in]

  • r (*) [real,in]

  • t (*) [real,in]

  • x0s (size(r) [real,out]

  • y0s (size(r) [real,out]

Called from:

get_circle_area_overlap()

subroutine  misc_functions_fortran/get_random_seed_size(size_bn)

Number of initial seeds expected by random_seed, to be initialised for a specified RNG setup.

Parameters:

size_bn [integer,out]