Skip to content

Commit 81fc93f

Browse files
committed
simplify real precision
1 parent dfca228 commit 81fc93f

18 files changed

Lines changed: 279 additions & 304 deletions

CITATION.cff

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ authors:
55
given-names: Michael
66
orcid: https://orcid.org/0000-0002-1637-6526
77
title: h5fortran
8-
version: 1.1.5
8+
version: 1.2.0
99
doi: 10.5281/zenodo.4589680
10-
date-released: 2021-11-08
10+
date-released: 2021-11-21

CMakeLists.txt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@ HOMEPAGE_URL https://github.com/geospace-code/maptran3d
1111

1212
include(CTest)
1313

14-
include(cmake/compilers.cmake)
15-
16-
if(realbits EQUAL 32)
17-
set(wp_real "wp=>real32")
18-
else()
19-
set(wp_real "wp=>real64")
14+
if(NOT realbits)
15+
set(realbits 32)
2016
endif()
2117

18+
include(cmake/compilers.cmake)
19+
2220
# --- Maptran library
2321
add_library(maptran)
2422
target_include_directories(maptran PUBLIC

README.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,21 @@ Similar to Python
99
and Matlab
1010
[Matmap3d](https://github.com/geospace-code/matmap3d).
1111

12-
## Install
12+
Default real precision is double precision (64 bit).
1313

14-
Requires Fortran 2008 compiler, such as `gfortran`, `ifort`, PGI, `nagfor`, `flang`, Cray, IBM XL, etc.
15-
Use CMake or Meson to build the suite, which creates `libmaptran.a` or similar.
16-
Compile-time polymorphism enabled by configuring with one of:
17-
18-
* `-Drealbits=32`
19-
* `-Drealbits=64`
14+
```sh
15+
cmake -B build
16+
cmake --build build
17+
```
2018

21-
The large real values typical of map coordinates can lead to large error with 32-bit reals.
22-
64-bit real is the default.
19+
Set 32-bit real by:
2320

2421
```sh
25-
cmake --preset=ninja
22+
cmake -B build -Drealbits=32
2623
cmake --build build
2724
```
2825

29-
## Usage
26+
which produces build/libmaptran.a or similar.
3027

3128
The modern Fortran API is simple like PyMap3D and Matlab Mapping Toolbox.
3229
`elemental` procedures are used throughout to enable seamless support of scalar or array coordinate inputs.
@@ -38,7 +35,7 @@ call geodetic2ecef(lat,lon,alt, x,y,z)
3835
call geodetic2aer(lat,lon,alt, observer_lat, observer_lon, observer_alt)
3936
```
4037

41-
### Functions
38+
## Functions
4239

4340
Popular mapping toolbox functions ported to Fortran include the
4441
following, where the source coordinate system (before the "2") is
@@ -61,7 +58,7 @@ Abbreviations:
6158
* [ENU: East North Up](https://en.wikipedia.org/wiki/Axes_conventions#Ground_reference_frames:_ENU_and_NED)
6259
* [NED: North East Down](https://en.wikipedia.org/wiki/North_east_down)
6360

64-
### Caveats
61+
## Caveats
6562

6663
* Atmospheric effects neglected in all functions.
6764
* Planetary perturbations and nutation etc. not fully considered.

cmake/compilers.cmake

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
if(CMAKE_Fortran_COMPILER_ID MATCHES "^Intel")
22
add_compile_options(
3+
-warn -traceback -heap-arrays
34
$<IF:$<BOOL:${WIN32}>,/QxHost,-xHost>
4-
"$<$<COMPILE_LANGUAGE:Fortran>:-warn;-traceback;-heap-arrays>"
5+
"$<$<CONFIG:Debug,RelWithDebInfo>:-check>"
6+
"$<IF:$<EQUAL:${realbits},32>,,-r8>"
57
)
68
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL GNU)
7-
add_compile_options(-mtune=native -Wall -Wextra
8-
"$<$<COMPILE_LANGUAGE:Fortran>:-fimplicit-none>"
9-
"$<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<CONFIG:Debug>>:-fcheck=all;-Werror=array-bounds>"
9+
add_compile_options(-mtune=native -Wall -fimplicit-none
10+
"$<$<CONFIG:Debug,RelWithDebInfo>:-fcheck=all;-Werror=array-bounds>"
11+
"$<IF:$<EQUAL:${realbits},32>,,-fdefault-real-8>"
1012
)
1113
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL NAG)
12-
add_compile_options("$<$<COMPILE_LANGUAGE:Fortran>:-f2018;-C;-colour;-gline;-nan;-info;-u>")
14+
add_compile_options(-f2018 -C -colour -gline -nan -info -u)
1315
endif()

codemeta.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"license": "https://spdx.org/licenses/BSD-2-Clause",
55
"codeRepository": "https://github.com/geospace-code/maptran3d",
66
"contIntegration": "https://github.com/geospace-code/maptran3d/actions",
7-
"dateModified": "2021-07-18",
7+
"dateModified": "2021-11-21",
88
"downloadUrl": "https://github.com/geospace-code/maptran3d/releases",
99
"issueTracker": "https://github.com/geospace-code/maptran3d/issues",
1010
"name": "maptran3d",
11-
"version": "1.1.5",
11+
"version": "1.2.0",
1212
"identifier": "10.5281/zenodo.4589680",
1313
"description": "Fortran coordinate transforms and geodesy",
1414
"applicationCategory": "geodesy",

meson.build

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ elif fc.get_id() == 'intel-cl'
99
add_project_arguments('/fpp', '/heap-arrays', language : 'fortran')
1010
endif
1111

12-
wp_real = get_option('realbits')=='32' ? 'wp=>real32' : 'wp=>real64'
13-
14-
wp_conf = configuration_data()
15-
wp_conf.set('wp_real', wp_real)
16-
1712
subdir('src')
1813
# --- Maptran library
1914
maptran = library('maptran',

meson_options.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/CMakeLists.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
configure_file(maptran.in.f90 maptran.f90 @ONLY)
2-
configure_file(vallado.in.f90 vallado.f90 @ONLY)
3-
41
target_sources(maptran PRIVATE
5-
${CMAKE_CURRENT_BINARY_DIR}/maptran.f90
6-
${CMAKE_CURRENT_BINARY_DIR}/vallado.f90
2+
maptran.f90
3+
vallado.f90
74
aer.f90 ecef.f90 enu.f90 sphere.f90 utils.f90
85
)

src/aer.f90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
!! az: azimuth clockwise from local north
2222
!! el: elevation angle above local horizon
2323

24-
real(wp) :: east, north, up
24+
real :: east, north, up
2525

2626
call ecef2enu(x, y, z, lat0, lon0, alt0, east, north, up, spheroid, deg)
2727
call enu2aer(east, north, up, az, el, slantRange, deg)
@@ -45,7 +45,7 @@
4545
! -------
4646
! x,y,z: Earth Centered Earth Fixed (ECEF) coordinates of test point (meters)
4747

48-
real(wp) :: x0,y0,z0, e,n,u,dx,dy,dz
48+
real :: x0,y0,z0, e,n,u,dx,dy,dz
4949

5050
!> Origin of the local system in geocentric coordinates.
5151
call geodetic2ecef(lat0, lon0, alt0,x0, y0, z0, spheroid,deg)
@@ -77,7 +77,7 @@
7777
! az: azimuth clockwise from local north
7878
! el: elevation angle above local horizon
7979

80-
real(wp) :: east,north,up
80+
real :: east,north,up
8181

8282

8383
call geodetic2enu(lat, lon, alt, lat0, lon0, alt0, east,north,up, spheroid, deg)
@@ -102,7 +102,7 @@
102102
!!
103103
!! * lat1,lon1,alt1: geodetic coordinates of test points (degrees,degrees,meters)
104104

105-
real(wp) :: x,y,z
105+
real :: x,y,z
106106

107107
call aer2ecef(az, el, slantRange, lat0, lon0, alt0, x, y, z, spheroid, deg)
108108

src/ecef.f90

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
!! You, Rey-Jer. (2000). Transformation of Cartesian to Geodetic Coordinates without Iterations.
1212
!! Journal of Surveying Engineering. doi: 10.1061/(ASCE)0733-9453
1313

14-
real(wp) :: ea, eb, r, E, u, Q, huE, Beta, eps, sinBeta, cosBeta
14+
real :: ea, eb, r, E, u, Q, huE, Beta, eps, sinBeta, cosBeta
1515
type(Ellipsoid) :: ell
1616
logical :: d, inside
1717

@@ -61,7 +61,7 @@
6161
alt = hypot(z - eb * sinBeta, Q - ea * cosBeta)
6262

6363
!> inside ellipsoid?
64-
inside = x**2 / ea**2 + y**2 / ea**2 + z**2 / eb**2 < 1._wp
64+
inside = x**2 / ea**2 + y**2 / ea**2 + z**2 / eb**2 < 1
6565
if (inside) alt = -alt
6666
endif
6767

@@ -91,7 +91,7 @@
9191
!!
9292
!! * x,y,z: ECEF coordinates of test point(s) (meters)
9393

94-
real(wp) :: N, sinLat, cosLat, cosLon, sinLon, lat, lon
94+
real :: N, sinLat, cosLat, cosLon, sinLon, lat, lon
9595
type(Ellipsoid) :: ell
9696
logical :: d
9797

@@ -166,7 +166,7 @@
166166
! -------
167167
! x,y,z: Earth Centered Earth Fixed (ECEF) coordinates of test point (meters)
168168

169-
real(wp) :: x0,y0,z0,dx,dy,dz
169+
real :: x0,y0,z0,dx,dy,dz
170170

171171
call geodetic2ecef(lat0, lon0, alt0, x0, y0, z0, spheroid, deg)
172172
call enu2uvw(e, n, u, lat0, lon0, dx, dy, dz, deg)
@@ -191,7 +191,7 @@
191191
!!
192192
!! * e,n,u: East, North, Up coordinates of test points (meters)
193193

194-
real(wp) :: x0,y0,z0
194+
real :: x0,y0,z0
195195

196196
call geodetic2ecef(lat0, lon0, alt0, x0,y0,z0, spheroid,deg)
197197
call ecef2enuv(x - x0, y - y0, z - z0, lat0, lon0, east, north, up, deg)
@@ -211,7 +211,7 @@
211211
!!
212212
!! * east,north,Up: East, North, Up vector
213213

214-
real(wp) :: t, lat0, lon0
214+
real :: t, lat0, lon0
215215
logical :: d
216216

217217
d=.true.
@@ -231,9 +231,9 @@
231231
end procedure ecef2enuv
232232

233233

234-
elemental real(wp) function radius_normal(lat,E)
234+
elemental real function radius_normal(lat,E)
235235

236-
real(wp), intent(in) :: lat
236+
real, intent(in) :: lat
237237
type(Ellipsoid), intent(in) :: E
238238

239239
!> singularity pi/2 issue is inherent to real32

0 commit comments

Comments
 (0)