Skip to content

Instantly share code, notes, and snippets.

@saweiss
Last active March 15, 2018 00:55
Show Gist options
  • Save saweiss/d1ba2d9f02d08a02cf341d1651988438 to your computer and use it in GitHub Desktop.
Save saweiss/d1ba2d9f02d08a02cf341d1651988438 to your computer and use it in GitHub Desktop.
NOVAS Fortran Version 3.1 Makefile
Naval Observatory Vector Astrometry Software (NOVAS) Fortran Version 3.1 Makefile
See the comments at the top of the Makefile for usage details.
Makefile by Samuel A. Weiss (sweiss1993@gmail.com and saweiss on GitHub).
References:
Kaplan, G., Bartlett, J., Monet, A., Bangert, J., & Puatua, W. (2011)
User's Guide to NOVAS Version F3.1 (Washington, DC: USNO).
See the official NOVAS website:
http://aa.usno.navy.mil/software/novas/novas_info.php
MIT License
Copyright (c) 2018 Samuel A. Weiss
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# This Makefile is an unofficial supplement to the NOVAS Fortran library
# (version 3.1). See the reference below for the original NOVAS library.
#
# Using this Makefile on UNIX-like machines should work, but nothing is
# guaranteed. You might have to tweak this file.
#
# NOTE:
# Before using this file, it is recommended (but not required) that the
# following changes are made to the official NOVAS Fortran 3.1 package:
#
# 1) In `NOVAS_F3.1.f` on line 3222, change:
# YY = SINX * SINY * SINL + COSY * COSL
# by adding a minus sign before the expression on the right:
# YY = -SINX * SINY * SINL + COSY * COSL
# 2) In each Fortran source file, remove trailing white space.
# It is recommended that a built in editor function is used
# to do this automatically, e.g., Emacs has a function called
# `delete-trailing-whitespace`. This can prevent a compiler
# warning.
# 3) In each output file (any *.out* file), use the command line
# tool called `dos2unix` to remove the DOS line endings from
# the files. You might have to download this tool from your
# package manager.
# 4) If you want to compare the given `example.out` file with
# your own (`my_example.out`), add a space before each line
# in `example.out`. Using `diff` on these files will then have
# less false flags due to spacing mismatch.
# 5) Running make after applying the above changes should still
# yield a few warning messages. Technically, these are not
# critical and do not need to be fixed. If you would like to
# fix the warnings, there should be three kinds:
#
# i) The dummy parameter warning can be silenced by adding
# N = 0
# somewhere inside `MPSTAR` in `NOVAS_F3.1.f`.
# ii) The unused label warning can be fixed by deleting
# the number labels at the beginning of each line that
# the compiler complained about. Make sure to only delete
# the numbers at the start of the line and not the rest
# of the line that follows.
# iii) The warning about implicit conversion from FLOAT to INT
# can be fixed by wrapping the right side of each expression
# that the compiler complains about with INT().
#
# Installation Steps:
# $ make
# $ make check
# $ make install
#
# Clean the Directory:
# $ make clean
#
# Uninstall:
# $ make uninstall
#
# Run the Example Code:
# $ make example
#
# NOTE:
# By default, `NOVAS_F3.1_solsys1.f` is used. If you want to use
# solsys3, just change the `v` variable below to `3`. See the official
# manual to see how to implement solsys2. Some small modifications will
# have to be made to this Makefile to make solsys2 work.
#
# Assuming solsys1 is used, `SS_EPHEM.TXT` and optionally `CIO_RA.TXT`
# must be copied to the source directory for your personal project that
# utilizes NOVAS. If you want to make `CIO_RA.TXT` into a binary file,
# see the manual. This Makefile, does not do that.
#
# The `make install` command, by default, installs the NOVAS shared
# library to /usr/local/lib. Modify the variables below to change the
# default location, if necessary.
#
# Compile and link your project using NOVAS with the `-lnovas` flag.
#
# Makefile by Samuel A. Weiss (sweiss1993@gmail.com and saweiss on GitHub).
#
# References:
# Kaplan, G., Bartlett, J., Monet, A., Bangert, J., & Puatua, W. (2011)
# User's Guide to NOVAS Version F3.1 (Washington, DC: USNO).
#
# See the official NOVAS website:
# http://aa.usno.navy.mil/software/novas/novas_info.php
# Compiler
FC = gfortran
# Compiler flags
FCFLAGS = -Wall -O3 -std=legacy -fPIC
# Name of the library made by this makefile
lib = libnovas.dylib
# The solsys file to use (1 or 3). See the manual if you want to use 2.
v := 1
# Objects to compile
objects = NOVAS_F3.1.o NOVAS_F3.1_solsys$(v).o
# Root directory for the install
PREFIX = /usr/local
# Directory for the library
libdir = $(PREFIX)/lib
# Shell used for processing recipes
SHELL = /bin/sh
# Clear suffixes list and add only those used for this program.
.SUFFIXES :
.SUFFIXES : .f .o .dylib
# Makefile rules
all : $(objects)
$(FC) -shared -o $(lib) $^
%.o : %.f
$(FC) $(FCFLAGS) -c $<
check :
$(FC) -L. -Wl,-rpath,. checkout.f -lnovas -o checkout
@mkdir tmp
@mv CIO_RA.TXT ./tmp
./checkout
@echo
@echo Make sure checkout.out.$(v) does not have DOS line ends if tests fail.
@echo The following diff should show no changes:
@echo
-diff checkout.out.$(v) checkout.out
mv checkout.out my_checkout_int.out
@mv ./tmp/CIO_RA.TXT .
@rm -fdr tmp
@echo
./checkout
@echo
@echo The following diff should only show that the external CIO is now used:
@echo
-diff checkout.out.$(v) checkout.out
mv checkout.out my_checkout_ext.out
example :
$(FC) -L. -Wl,-rpath,. example.f -lnovas -o example
./example > my_example.out
.PHONY: clean clean_objects clean_check clean_example install uninstall
clean : clean_objects clean_check clean_example
clean_objects :
rm -fdr *.o *.dylib
clean_check :
rm -fdr checkout checkout.out my_checkout_int.out my_checkout_ext.out *.dSYM
clean_example :
rm -fdr example my_example.out
install : $(lib)
sudo cp $< $(libdir)
uninstall : $(lib)
sudo rm $(libdir)/$<
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment