htmie

Optical properties of water droplets
git clone git://git.meso-star.fr/htmie.git
Log | Files | Refs | README | LICENSE

commit 31f35590721151d80f2811ca74bb4a4f462ef5fd
parent 861ac140918578a4aadc79ec912ff109ea4b9e45
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Mon, 30 Oct 2023 16:16:59 +0100

Merge branch 'release_0.1'

Diffstat:
D.gitattributes | 1-
M.gitignore | 19++++++++++++-------
AMakefile | 182+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AMie_LUT_Cloud.cdl | 499+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DMie_LUT_Cloud.nc | 2--
MREADME.md | 74+++++++++++++++++++++++++++++++++++++++++++++-----------------------------
Dcmake/CMakeLists.txt | 172-------------------------------------------------------------------------------
Dcmake/FindNetCDF.cmake | 119-------------------------------------------------------------------------------
Aconfig.mk | 84+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ddoc/htmie.5.scd | 54------------------------------------------------------
Adummy.cdl | 27+++++++++++++++++++++++++++
Ahtmie.5 | 58++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ahtmie.pc.in | 11+++++++++++
Amake.sh | 72++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/dump_netcdf_data.sh | 23+++++++++++++----------
Msrc/htmie.c | 17+++++++++++------
Msrc/htmie.h | 2+-
Msrc/test_htmie.c | 2+-
Msrc/test_htmie_load.c | 28++++++----------------------
Msrc/test_htmie_utils.h | 2+-
20 files changed, 1023 insertions(+), 425 deletions(-)

diff --git a/.gitattributes b/.gitattributes @@ -1 +0,0 @@ -Mie_LUT_Cloud.nc filter=wad diff --git a/.gitignore b/.gitignore @@ -1,12 +1,17 @@ .gitignore -CMakeCache.txt -CMakeFiles -Makefile -tmp [Bb]uild* *.sw[po] -*.[ao] -*.orig +*.[aod] +*.so *~ +test* +!test*.[ch] +.config +.test tags -*.htcp +*.g +*.lambda +*.macs +*.mscs +*.nc +*.pc diff --git a/Makefile b/Makefile @@ -0,0 +1,182 @@ +# Copyright (C) 2018, 2020-2023 |Méso|Star> (contact@meso-star.com) +# Copyright (C) 2018 Centre National de la Recherche Scientifique +# Copyright (C) 2018 Université Paul Sabatier +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +.POSIX: +.SUFFIXES: # Clean up default inference rules + +include config.mk + +LIBNAME_STATIC = libhtmie.a +LIBNAME_SHARED = libhtmie.so +LIBNAME = $(LIBNAME_$(LIB_TYPE)) + +################################################################################ +# Library building +################################################################################ +SRC = src/htmie.c +OBJ = $(SRC:.c=.o) +DEP = $(SRC:.c=.d) + +build_library: .config $(DEP) + @$(MAKE) -fMakefile $$(for i in $(DEP); do echo -f $${i}; done) \ + $$(if [ -n "$(LIBNAME)" ]; then \ + echo "$(LIBNAME)"; \ + else \ + echo "$(LIBNAME_SHARED)"; \ + fi) + +$(DEP) $(OBJ): config.mk + +$(LIBNAME_SHARED): $(OBJ) + $(CC) $(CFLAGS_SO) $(DPDC_CFLAGS) -o $@ $(OBJ) $(LDFLAGS_SO) $(DPDC_LIBS) + +$(LIBNAME_STATIC): libhtmie.o + $(AR) -rc $@ $? + $(RANLIB) $@ + +libhtmie.o: $(OBJ) + $(LD) -r $(OBJ) -o $@ + $(OBJCOPY) $(OCPFLAGS) $@ + +.config: config.mk + @if ! $(PKG_CONFIG) --atleast-version $(NETCDF_VERSION) netcdf; then \ + echo "netcdf $(NETCDF_VERSION) not found" >&2; exit 1; fi + @if ! $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys; then \ + echo "rsys $(RSYS_VERSION) not found" >&2; exit 1; fi + @echo "config done" > $@ + +.SUFFIXES: .c .d .o +.c.d: + @$(CC) $(CFLAGS_SO) $(DPDC_CFLAGS) -MM -MT "$(@:.d=.o) $@" $< -MF $@ + +.c.o: + $(CC) $(CFLAGS_SO) $(DPDC_CFLAGS) -DHTMIE_SHARED_BUILD -c $< -o $@ + +################################################################################ +# Installation +################################################################################ +pkg: + sed -e 's#@PREFIX@#$(PREFIX)#g'\ + -e 's#@VERSION@#$(VERSION)#g'\ + -e 's#@NETCDF_VERSION@#$(NETCDF_VERSION)#g'\ + -e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\ + htmie.pc.in > htmie.pc + +htmie-local.pc: htmie.pc.in + sed -e '1d'\ + -e 's#^includedir=.*#includedir=./src/#'\ + -e 's#^libdir=.*#libdir=./#'\ + -e 's#@VERSION@#$(VERSION)#g'\ + -e 's#@NETCDF_VERSION@#$(NETCDF_VERSION)#g'\ + -e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\ + htmie.pc.in > $@ + +install: build_library pkg + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib" $(LIBNAME) + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib/pkgconfig" htmie.pc + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/include/high_tune" src/htmie.h + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/share/doc/htmie" COPYING README.md + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/share/man/man5" htmie.5 + +uninstall: + rm -f "$(DESTDIR)$(PREFIX)/lib/$(LIBNAME)" + rm -f "$(DESTDIR)$(PREFIX)/lib/pkgconfig/htmie.pc" + rm -f "$(DESTDIR)$(PREFIX)/share/doc/htmie/COPYING" + rm -f "$(DESTDIR)$(PREFIX)/share/doc/htmie/README.md" + rm -f "$(DESTDIR)$(PREFIX)/include/high_tune/htmie.h" + rm -f "$(DESTDIR)$(PREFIX)/share/man/man5/htmie.5" + +################################################################################ +# Miscellaneous targets +################################################################################ +all: build_library build_tests + +clean: clean_test + rm -f $(OBJ) $(TEST_OBJ) $(LIBNAME) + rm -f .config .test libhtmie.o htmie.pc htmie-local.pc + +distclean: clean + rm -f $(DEP) $(TEST_DEP) + +lint: + shellcheck -o all make.sh + shellcheck -o all src/dump_netcdf_data.sh + mandoc -Tlint -Wall htmie.5 || [ $$? -le 1 ] + +################################################################################ +# Tests +################################################################################ +TEST_SRC = src/test_htmie.c src/test_htmie_load.c +TEST_OBJ = $(TEST_SRC:.c=.o) +TEST_DEP = $(TEST_SRC:.c=.d) + +TEST_MIE_LUT = Mie_LUT_Cloud +TEST_MIE_LUT_CDL = $(TEST_MIE_LUT).cdl +TEST_MIE_LUT_NETCDF = $(TEST_MIE_LUT).nc +TEST_MIE_LUT_VARS =\ + $(TEST_MIE_LUT).g\ + $(TEST_MIE_LUT).lambda\ + $(TEST_MIE_LUT).macs\ + $(TEST_MIE_LUT).mscs + +TEST_DUMMY = dummy +TEST_DUMMY_CDL = $(TEST_DUMMY).cdl +TEST_DUMMY_NETCDF = $(TEST_DUMMY).nc +TEST_DUMMY_VARS =\ + $(TEST_DUMMY).g\ + $(TEST_DUMMY).lambda\ + $(TEST_DUMMY).macs\ + $(TEST_DUMMY).mscs + +PKG_CONFIG_LOCAL = PKG_CONFIG_PATH="./:$${PKG_CONFIG_PATH}" $(PKG_CONFIG) +HTMIE_CFLAGS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags htmie-local.pc) +HTMIE_LIBS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --libs htmie-local.pc) + +test: $(TEST_MIE_LUT_VARS) $(TEST_MIE_LUT_NETCDF) +test: $(TEST_DUMMY_VARS) $(TEST_DUMMY_NETCDF) +test: build_tests + @$(SHELL) make.sh check test_htmie test_htmie + @$(SHELL) make.sh check test_htmie_load_LUT test_htmie_load Mie_LUT_Cloud.nc . + @$(SHELL) make.sh check test_htmie_load_dummy test_htmie_load dummy.nc . + +.SUFFIXES: .cdl .nc .g .lambda .macs .mscs +.cdl.nc: + ncgen -o $@ $< + +.nc.g .nc.lambda .nc.macs .nc.mscs: + $(SHELL) src/dump_netcdf_data.sh $$(p="$@"; echo "$${p##*.}") $< > $@ + +build_tests: build_library $(TEST_DEP) .test $(TEST_MIE_LUT_VARS) $(TEST_DUMMY_VARS) + @$(MAKE) -fMakefile -f.test $$(for i in $(TEST_DEP); do echo -f"$${i}"; done) test_bin + +.test: Makefile make.sh + @$(SHELL) make.sh config_test $(TEST_SRC) > $@ + +clean_test: + $(SHELL) make.sh clean_test $(TEST_SRC) + rm -rf $(TEST_MIE_LUT_VARS) $(TEST_MIE_LUT_NETCDF) + rm -rf $(TEST_DUMMY_VARS) $(TEST_DUMMY_NETCDF) + +$(TEST_DEP): config.mk htmie-local.pc + @$(CC) $(CFLAGS_EXE) $(HTMIE_CFLAGS) $(RSYS_CFLAGS) \ + -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@ + +$(TEST_OBJ): config.mk htmie-local.pc + $(CC) $(CFLAGS_EXE) $(HTMIE_CFLAGS) $(RSYS_CFLAGS) -c $(@:.o=.c) -o $@ + +test_htmie test_htmie_load: config.mk htmie-local.pc $(LIBNAME) + $(CC) $(CFLAGS_EXE) -o $@ src/$@.o $(LDFLAGS_EXE) $(HTMIE_LIBS) $(RSYS_LIBS) -lm diff --git a/Mie_LUT_Cloud.cdl b/Mie_LUT_Cloud.cdl @@ -0,0 +1,499 @@ +netcdf Mie_LUT_Cloud { +dimensions: + lambda = 557 ; + distribution = UNLIMITED ; // (1 currently) +variables: + double lambda(lambda) ; + lambda:long_name = "Wavelength" ; + lambda:units = "nanometers" ; + double mscs(distribution, lambda) ; + mscs:long_name = "Massic scattering cross section" ; + mscs:units = "m^2/kg" ; + double macs(distribution, lambda) ; + macs:long_name = "Massic absorption cross section" ; + macs:units = "m^2/kg" ; + double g(distribution, lambda) ; + g:long_name = "Asymmetry parameter" ; + g:units = "-" ; +data: + + lambda = 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475, 500, + 525, 550, 575, 600, 625, 650, 675, 700, 725, 750, 775, 800, 825, 850, + 875, 900, 925, 950, 975, 1000, 1025, 1050, 1075, 1100, 1125, 1150, 1175, + 1200, 1225, 1250, 1275, 1300, 1325, 1350, 1375, 1400, 1425, 1450, 1475, + 1500, 1525, 1550, 1575, 1600, 1625, 1650, 1675, 1700, 1725, 1750, 1775, + 1800, 1825, 1850, 1875, 1900, 1925, 1950, 1975, 2000, 2025, 2050, 2075, + 2100, 2125, 2150, 2175, 2200, 2225, 2250, 2275, 2300, 2325, 2350, 2375, + 2400, 2425, 2450, 2475, 2500, 2525, 2550, 2575, 2600, 2625, 2650, 2675, + 2700, 2725, 2750, 2775, 2800, 2825, 2850, 2875, 2900, 2925, 2950, 2975, + 3000, 3025, 3050, 3075, 3100, 3125, 3150, 3175, 3200, 3225, 3250, 3275, + 3300, 3325, 3350, 3375, 3400, 3425, 3450, 3475, 3500, 3525, 3550, 3575, + 3600, 3625, 3650, 3675, 3700, 3725, 3750, 3775, 3800, 3825, 3850, 3875, + 3900, 3925, 3950, 3975, 4000, 4025, 4050, 4075, 4100, 4125, 4150, 4175, + 4200, 4225, 4250, 4275, 4300, 4325, 4350, 4375, 4400, 4425, 4450, 4475, + 4500, 4525, 4550, 4575, 4600, 4625, 4650, 4675, 4700, 4725, 4750, 4775, + 4800, 4825, 4850, 4875, 4900, 4925, 4950, 4975, 5000, 5025, 5050, 5075, + 5100, 5125, 5150, 5175, 5200, 5225, 5250, 5275, 5300, 5325, 5350, 5375, + 5400, 5425, 5450, 5475, 5500, 5525, 5550, 5575, 5600, 5625, 5650, 5675, + 5700, 5725, 5750, 5775, 5800, 5825, 5850, 5875, 5900, 5925, 5950, 5975, + 6000, 6025, 6050, 6075, 6100, 6125, 6150, 6175, 6200, 6225, 6250, 6275, + 6300, 6325, 6350, 6375, 6400, 6425, 6450, 6475, 6500, 6525, 6550, 6575, + 6600, 6625, 6650, 6675, 6700, 6725, 6750, 6775, 6800, 6825, 6850, 6875, + 6900, 6925, 6950, 6975, 7000, 7025, 7050, 7075, 7100, 7125, 7150, 7175, + 7200, 7225, 7250, 7275, 7300, 7325, 7350, 7375, 7400, 7425, 7450, 7475, + 7500, 7525, 7550, 7575, 7600, 7625, 7650, 7675, 7700, 7725, 7750, 7775, + 7800, 7825, 7850, 7875, 7900, 7925, 7950, 7975, 8000, 8025, 8050, 8075, + 8100, 8125, 8150, 8175, 8200, 8225, 8250, 8275, 8300, 8325, 8350, 8375, + 8400, 8425, 8450, 8475, 8500, 8525, 8550, 8575, 8600, 8625, 8650, 8675, + 8700, 8725, 8750, 8775, 8800, 8825, 8850, 8875, 8900, 8925, 8950, 8975, + 9000, 9025, 9050, 9075, 9100, 9125, 9150, 9175, 9200, 9225, 9250, 9275, + 9300, 9325, 9350, 9375, 9400, 9425, 9450, 9475, 9500, 9525, 9550, 9575, + 9600, 9625, 9650, 9675, 9700, 9725, 9750, 9775, 9800, 9825, 9850, 9875, + 9900, 9925, 9950, 9975, 10000, 10025, 10050, 10075, 10100, 10125, 10150, + 10175, 10200, 10225, 10250, 10275, 10300, 10325, 10350, 10375, 10400, + 10425, 10450, 10475, 10500, 10525, 10550, 10575, 10600, 10625, 10650, + 10675, 10700, 10725, 10750, 10775, 10800, 10825, 10850, 10875, 10900, + 10925, 10950, 10975, 11000, 11025, 11050, 11075, 11100, 11125, 11150, + 11175, 11200, 11225, 11250, 11275, 11300, 11325, 11350, 11375, 11400, + 11425, 11450, 11475, 11500, 11525, 11550, 11575, 11600, 11625, 11650, + 11675, 11700, 11725, 11750, 11775, 11800, 11825, 11850, 11875, 11900, + 11925, 11950, 11975, 12000, 12025, 12050, 12075, 12100, 12125, 12150, + 12175, 12200, 12225, 12250, 12275, 12300, 12325, 12350, 12375, 12400, + 12425, 12450, 12475, 12500, 12525, 12550, 12575, 12600, 12625, 12650, + 12675, 12700, 12725, 12750, 12775, 12800, 12825, 12850, 12875, 12900, + 12925, 12950, 12975, 13000, 13025, 13050, 13075, 13100, 13125, 13150, + 13175, 13200, 13225, 13250, 13275, 13300, 13325, 13350, 13375, 13400, + 13425, 13450, 13475, 13500, 13525, 13550, 13575, 13600, 13625, 13650, + 13675, 13700, 13725, 13750, 13775, 13800, 13825, 13850, 13875, 13900, + 13925, 13950, 13975, 14285.7142857143, 15873.0158730159, 20000, + 28571.4285714286, 1000000 ; + + mscs = + 148.583778410196, 148.848607519154, 149.100978411304, 149.342064326765, + 149.574028880445, 149.802049337651, 150.023874602563, 150.24165974607, + 150.455680177014, 150.660157974708, 150.86348985074, 151.063226460121, + 151.263898546171, 151.4558366866, 151.647010783959, 151.835717942437, + 152.021735266204, 152.203699968248, 152.386686605013, 152.564905199417, + 152.746224260916, 152.919688294662, 153.092235803507, 153.262897730282, + 153.436317031401, 153.605941025227, 153.773376351121, 153.936999357951, + 154.094265153435, 154.248952657195, 154.370732228002, 154.520174278004, + 154.694887370113, 154.847495030776, 155.001654827813, 155.14888683894, + 155.281549931818, 155.399699693891, 155.515470791846, 155.642095526838, + 155.79533625785, 155.749735923883, 155.736439556139, 155.731536563086, + 155.70565211911, 155.635563050558, 155.512061427315, 155.345127817122, + 155.162078886449, 155.281566066976, 155.45531762515, 155.716461613417, + 156.080059580795, 156.538738164808, 157.063314485539, 157.607900656574, + 158.11806445701, 158.424446900692, 158.594918144685, 158.602097539405, + 158.441952769528, 158.134696717014, 157.721815033895, 157.26061759025, + 156.816887515484, 155.238059011522, 153.888807209597, 152.800783523513, + 151.991210297392, 151.457543644096, 151.176777226674, 151.107647999134, + 151.194605365922, 153.251255330443, 155.320494791296, 157.31086094303, + 159.134546400886, 160.714914359538, 161.992201637275, 162.927820812342, + 163.506810676873, 161.927219876095, 159.958934390539, 157.706951683405, + 155.30360212355, 152.896850221541, 150.637284531793, 148.666727945616, + 147.107781775998, 144.6924151191, 143.680382110297, 144.072725273479, + 145.692164313001, 148.208314090688, 151.182326022723, 154.122751244968, + 156.544525842056, 151.40582113523, 141.784308826916, 113.016251112142, + 93.9443185651073, 81.6056333589263, 81.3186052106781, 79.441024840944, + 77.6846782830557, 76.9122302053857, 77.0805003449933, 78.388653044379, + 79.6956200067439, 80.7867908870612, 81.7782639158147, 82.2361755255173, + 82.7250501918472, 83.0156946029209, 83.3295734621302, 83.5094930651322, + 83.7275796012813, 83.783622720954, 83.9032214181802, 83.9549144377184, + 84.1935564524531, 84.6678743362649, 85.8832064595796, 87.9478656960605, + 92.1233598574172, 94.8519077497381, 98.3416598678102, 100.912669578709, + 104.029285536972, 107.853363774111, 112.731458472399, 116.112172462428, + 120.386164157526, 123.375598536712, 127.01120756751, 131.369765724965, + 136.513210263805, 139.582962842122, 142.998497164661, 146.724740885919, + 150.716755011555, 153.326745702918, 155.990814448721, 158.650900105112, + 161.2491225611, 162.731465415709, 164.085387502441, 165.2830103803, + 166.299900516313, 166.599782547121, 166.713692431082, 166.632319558675, + 166.349592469035, 165.619257166158, 164.720750006742, 163.657244121835, + 162.43385380181, 160.864990832914, 159.186586310643, 157.407019501153, + 155.535459134258, 153.304282716917, 151.017962079351, 148.68718775515, + 146.322862213771, 143.718055722259, 141.117744841198, 138.532234945325, + 135.971556067531, 132.880280693167, 129.91157114269, 127.064942782499, + 124.339798113715, 122.678876481531, 121.05395117237, 119.469001960439, + 117.927729708012, 116.797333444013, 115.697146368375, 114.628434509373, + 113.592341552787, 113.311018777121, 113.042603049672, 112.788749826793, + 112.551059489165, 112.400388529499, 112.281756634821, 112.198552486706, + 112.154047707902, 112.076477507044, 112.054759002961, 112.092878683829, + 112.194623437285, 112.363564160636, 112.60303777327, 112.916147477517, + 113.30575998253, 113.609508565395, 114.031733791834, 114.575673751835, + 115.244049751682, 115.72687653371, 116.335776041013, 117.070535233863, + 117.930441625635, 118.712141412026, 119.66545939261, 120.785008636444, + 122.06469290298, 123.146579997653, 124.374402308052, 125.738144769046, + 127.227507055807, 128.611494035211, 130.136994491232, 131.784077412694, + 133.533179886939, 134.496621378511, 135.574379754365, 136.723354559895, + 137.904716894119, 137.177742363543, 136.529097605987, 135.887268608218, + 135.197871585827, 129.473106980075, 124.481897116555, 120.029412628692, + 115.987328729495, 108.091836890397, 102.058286038484, 97.4111340260358, + 93.8078735896418, 91.0918760376475, 88.7612478831853, 86.8310103150264, + 85.2919930338467, 85.1766565752593, 84.840191174929, 84.3528558756667, + 83.8520401326336, 84.7462170324874, 85.9844003025228, 87.6818124415396, + 89.9903530434042, 91.8457270923123, 93.9851392859901, 96.4374617218249, + 99.233493565773, 101.330236610766, 103.585527140542, 106.003566591197, + 108.588288539889, 110.580212721219, 112.657194385681, 114.81934652639, + 117.066656975443, 119.016709940871, 121.01556967458, 123.061447575274, + 125.152480203893, 127.052894472293, 128.978609356556, 130.927274841667, + 132.896523789762, 134.422241325491, 135.953970213891, 137.490479950988, + 139.030554001052, 140.638296674825, 142.243222220423, 143.843676665264, + 145.438039057362, 146.801127228926, 148.155076024685, 149.498880270584, + 150.831564796474, 151.965449354506, 153.088590203323, 154.200445438548, + 155.30049366764, 156.533289050171, 157.749435508311, 158.948184447828, + 160.128818574718, 161.116269326219, 162.088309743767, 163.044585337218, + 163.984760197655, 165.035364085383, 166.063933411772, 167.069975674345, + 168.053027663842, 168.897674417398, 169.724377057447, 170.532931034974, + 171.323147912448, 172.157225194436, 172.965907305347, 173.748939827287, + 174.50609389083, 175.105209378639, 175.684516052327, 176.243980276785, + 176.78358087024, 177.380362746068, 177.950298497373, 178.49333631357, + 179.009444605779, 179.498611366242, 179.960843548558, 180.396166463992, + 180.804623187739, 181.163144501857, 181.498695343464, 181.811375804787, + 182.101297066544, 182.368580945027, 182.613359438425, 182.83577427442, + 183.035976461203, 183.170757235813, 183.283723449599, 183.375072216777, + 183.445007764422, 183.493741018918, 183.521489206336, 183.528475467662, + 183.514928489793, 183.454177694243, 183.369862166628, 183.262271387623, + 183.131701256089, 182.978453666803, 182.802836102603, 182.60516123783, + 182.385746551884, 182.103153976424, 181.799803090221, 181.476040623222, + 181.132216061487, 180.768681301272, 180.385790312274, 179.983898810485, + 179.563363941301, 179.070693188311, 178.556998700548, 178.022715873618, + 177.468281343588, 176.894132610236, 176.300707676725, 175.68844470577, + 175.057781692048, 174.370985913121, 173.667220633637, 172.946932789679, + 172.210567362347, 171.458567133798, 170.691372456116, 169.909421032177, + 169.113147707727, 168.208881463804, 167.28911912134, 166.354383454255, + 165.405193066051, 164.44206214839, 163.465500252579, 162.476012073742, + 161.474097247483, 160.41082374729, 159.337210545362, 158.253746552887, + 157.160914052278, 156.059188576483, 154.94903879953, 153.830926438063, + 152.705306163439, 151.359561459579, 150.005164184921, 148.642758797538, + 147.272978847476, 145.896446837681, 144.513774102071, 143.125560699892, + 141.732395325656, 140.198783557833, 138.661829415305, 137.122196284145, + 135.580532746123, 134.037472542696, 132.49363455567, 130.949622803739, + 129.406026454237, 127.305784531776, 125.224219731394, 123.161860330588, + 121.119205896161, 119.096727846417, 117.094870027612, 115.114049302801, + 113.154656151209, 111.217055276401, 109.301586221523, 107.40856399008, + 105.538279670685, 103.691001064353, 101.866973313033, 100.06641952807, + 98.2895414174441, 96.5365199106968, 94.8075157805291, 93.1026702601332, + 91.4221056554477, 89.4670073675076, 87.567861705909, 85.7233995876572, + 83.9323758315345, 82.1935687627424, 80.5057798340044, 78.8678332610789, + 77.2785756710439, 75.7368757617493, 74.2416239711338, 72.7917321552337, + 71.3861332737869, 70.0237810825992, 68.7036498318093, 67.4247339694043, + 66.186047849353, 64.9866254438312, 63.8255200591094, 62.7018040546804, + 61.6145685653037, 60.6182628914574, 59.6692270098939, 58.7655739250969, + 57.905495122833, 57.0872570128934, 56.3091975546317, 55.5697230542578, + 54.8673051237719, 54.2004777920623, 53.5678347593518, 52.9680267867616, + 52.3997592133189, 51.8617895932821, 51.3529254470371, 50.8720221193481, + 50.4179807390885, 49.9897462749666, 49.5863056821138, 49.2066861347127, + 48.8499533401236, 48.7307686625533, 48.6283321443085, 48.5417525839372, + 48.4701868522757, 48.4128371386293, 48.368948367071, 48.337805771521, + 48.3187326190696, 48.3110880717267, 48.3142651775192, 48.3276889824978, + 48.3508147557844, 48.3831263203502, 48.4241344827609, 48.4733755555378, + 48.5304099662334, 48.5948209477854, 48.6662133049745, 48.7442122522784, + 48.8284623186284, 49.1673421560414, 49.5020880561207, 49.832760941445, + 50.1594226999272, 50.4821359832919, 50.8009640238245, 51.1159704679461, + 51.4272192252477, 51.7347743317423, 52.0386998261942, 52.339059638455, + 52.6359174888548, 52.9293367977228, 53.2193806042459, 53.5061114938528, + 53.7895915334859, 54.0698822140432, 54.3470443994498, 54.621138281771, + 54.8922233418894, 55.1676800766011, 55.4398964441556, 55.7089289159286, + 55.9748330989112, 56.2376637388948, 56.4974747243994, 56.7543190913071, + 57.0082490281285, 57.2593158818348, 57.5075701642348, 57.7530615588328, + 57.9958389281113, 58.235950321211, 58.4734429819777, 58.7083633573046, + 58.9407571057892, 59.170669106607, 59.3981434686374, 59.6232235397804, + 59.8459519164187, 60.0812091191009, 60.3143286846769, 60.5453337852934, + 60.7742475508824, 61.00109305813, 61.2258933200823, 61.4486712763267, + 61.6694497837225, 61.888251607675, 62.1050994139149, 62.3200157607775, + 62.5330230919372, 62.7441437295895, 62.9533998680765, 63.1608135679007, + 63.3664067501526, 63.5702011912846, 63.7722185182727, 63.9724802040904, + 64.1710075635304, 64.3480637709267, 64.5241287353843, 64.6992048496759, + 64.873294674989, 65.046400934365, 65.2185265063395, 65.3896744187549, + 65.5598478427365, 65.7290500868609, 65.8972845914601, 66.0645549231233, + 66.2308647693207, 66.3962179332031, 66.5606183285442, 66.724069974834, + 66.8865769925019, 67.048143598291, 67.2087741007673, 67.3684728959561, + 68.9935770184662, 75.3235780975798, 86.6086636223597, 84.355229793588, + 0.00178685699862044 ; + + macs = + 0.00953151443298881, 0.00376469098500625, 0.00235556776982531, + 0.0015104902771344, 0.000966503364977031, 0.000587408178248459, + 0.000326554488805506, 0.000173835786653858, 8.69924730979348e-05, + 5.48752837973682e-05, 4.13801039341414e-05, 3.66415442628672e-05, + 3.72143226911033e-05, 4.61199285306809e-05, 6.63755466047781e-05, + 0.00011472579825772, 0.000342780795383973, 0.000406187922611402, + 0.000483756453519437, 0.000635210040127064, 0.000907656489621037, + 0.00238425573998917, 0.00405773786686297, 0.00367621573034185, + 0.00310885704102609, 0.004486351852423, 0.00677584585604105, + 0.00868676426231702, 0.0103776229287896, 0.0221751974278872, + 0.0588387537092452, 0.0681883701735902, 0.0562536784405035, + 0.0712361565694729, 0.0852356122868849, 0.0982970230755011, + 0.112050222444211, 0.124434128542843, 0.136805515948656, + 0.14780317424606, 0.158988247381456, 0.401988605339471, + 0.632567907278131, 0.852668055189882, 1.06314800462629, 1.26483397414963, + 1.45870374634609, 1.64533721476559, 1.82518258459836, 1.71584641406101, + 1.61031369571714, 1.5082066098175, 1.40927008078269, 1.31310381382309, + 1.21941417580497, 1.12791467260463, 1.03840507595267, 1.06901283189361, + 1.09881590469445, 1.12784010899505, 1.15607350411223, 1.18354131494882, + 1.21021246206733, 1.23612355891429, 1.26126800935692, 2.50590576004724, + 3.67896678864524, 4.79422061922412, 5.85929905946168, 6.87941172405585, + 7.85853031235457, 8.79986113123517, 9.70610889095195, 8.81685938756723, + 7.927685125205, 7.0376309167356, 6.14601328348518, 5.25246249753737, + 4.35687909781618, 3.45949448647924, 2.56084878263356, 3.23121691721055, + 3.87654362388858, 4.49865712328601, 5.0990177134584, 5.67885351673455, + 6.23920310050926, 6.78098646551859, 7.30502402130622, 9.13157669125806, + 10.8556274412304, 12.4856746619624, 14.0285585074716, 15.4900268208397, + 16.8749926313173, 18.1878220209612, 19.432386965745, 27.525726010992, + 34.2294439952429, 51.7745882099834, 62.2403077046973, 77.0238621367031, + 80.3124896091833, 81.0729530352245, 80.63605269769, 80.0857083588116, + 79.4490209192706, 78.9987387236655, 78.4725902363478, 78.5416034800439, + 78.4603271392086, 78.7583384252695, 78.9394851661901, 79.1327735503206, + 79.2665572769708, 79.5066301547329, 79.693380808317, 80.0117926263085, + 80.2840431567263, 80.5616570509637, 80.715537420548, 80.651717341915, + 79.9805126777231, 78.4858235827139, 74.8911483566319, 72.0605360232593, + 67.9659346658551, 64.5538338662045, 60.2958888096685, 55.2452706690869, + 49.0129225148665, 44.5227775508464, 39.4128989624039, 36.1981095225883, + 32.7372196988294, 29.005856454909, 24.9762535290898, 23.3579066396882, + 21.6957633904922, 19.9892357435494, 18.2381324591672, 17.9161032803034, + 17.5926855768391, 17.2680522314931, 16.9425085359285, 17.2669817417872, + 17.5843231468239, 17.8946082691049, 18.1980041027992, 18.9034917928934, + 19.5909592083132, 20.2610173417322, 20.9141805686491, 21.7618435569559, + 22.5863459490589, 23.3885897168354, 24.1693797157494, 25.1416432090499, + 26.0856535802234, 27.0025428945861, 27.8933905220917, 29.0035072410791, + 30.078124390243, 31.1187974248916, 32.1270091250767, 33.3026747305261, + 34.4382411120192, 35.5355418161795, 36.5962671264841, 38.4209459369706, + 40.1591255891838, 41.8162074259616, 43.3971556313586, 43.9468693800269, + 44.4837796879605, 45.0082653651884, 45.5207024764916, 45.8851924223566, + 46.2432097935462, 46.5949196878078, 46.9404833220507, 46.455216305247, + 45.9677240895445, 45.4780630839346, 44.9862966561744, 44.171597118143, + 43.3478446354292, 42.5151685016712, 41.673702121358, 40.8152391626368, + 39.9481777202538, 39.072680697804, 38.1889211327614, 37.2970764453491, + 36.3973206355569, 35.4898314420277, 34.5747908387237, 33.8154327605833, + 33.0528299755322, 32.2871777873519, 31.5186765710296, 31.1782162185803, + 30.8387755863965, 30.5004107132282, 30.1631800150614, 30.298869023211, + 30.4311025573399, 30.5599345205257, 30.6854234012367, 31.2742776694368, + 31.8477538199568, 32.4062966822238, 32.9503363762597, 34.1620961667226, + 35.3270020102987, 36.4471259189715, 37.524420360471, 40.1656048217664, + 42.6200795029751, 44.902811710642, 47.0273037795581, 51.2738083628325, + 54.9937903370204, 58.2580611777535, 61.1266264243033, 66.95348988932, + 71.4123908042174, 74.8372512105137, 77.4749999943267, 80.9659974818844, + 83.4162675992045, 85.1386126307379, 86.3472583416528, 87.2554989482944, + 88.0096370107287, 88.6279819690902, 89.1271172229608, 89.1141057093144, + 88.8941453163203, 88.3801198290803, 87.447510940831, 86.1967226115341, + 84.5089817836156, 82.2586133298949, 79.2830170455438, 77.7646511951897, + 76.0744528188925, 74.1965902748424, 72.1138617976469, 70.9668652623062, + 69.7636092969858, 68.5023945950448, 67.1814960136081, 66.2750005253546, + 65.3425561735611, 64.3838486795645, 63.3985666710871, 62.7839585590738, + 62.1610379000421, 61.529876842484, 60.8905483765621, 60.4653130056615, + 60.0374779167068, 59.6071149247911, 59.1742956358695, 58.891638527371, + 58.6084185936714, 58.3246654970173, 58.040408686837, 57.8198602839977, + 57.5992093009622, 57.3784792546009, 57.1576928418319, 57.0016834227823, + 56.8458023590438, 56.690058973121, 56.5344621235601, 56.4181019814793, + 56.3019364518124, 56.1859690275682, 56.0702032609096, 55.9412437143429, + 55.8124405462511, 55.6838004532896, 55.5553301216612, 55.4661193659449, + 55.3770681775164, 55.288179450357, 55.19945591571, 55.0973025197942, + 54.9952748441262, 54.8933770947674, 54.7916131559027, 54.7036793792471, + 54.6159246017431, 54.5283501057054, 54.4409571483146, 54.3650049731886, + 54.2890911582352, 54.2132189253246, 54.1373915409214, 54.1001953026957, + 54.0629459036932, 54.0256457225273, 53.9882971378658, 53.936986752318, + 53.885595527961, 53.8341271295222, 53.7825850522974, 53.7309726021261, + 53.6792928887664, 53.6275488332946, 53.5757431875454, 53.5309121724222, + 53.486040269749, 53.4411292477202, 53.396180836646, 53.3511967503547, + 53.3061787026531, 53.2611284187967, 53.2160476422288, 53.1941307681996, + 53.1720273193475, 53.1497404012595, 53.1272731166545, 53.1046285562596, + 53.0818097880618, 53.0588198459162, 53.0356617183525, 53.0164444281102, + 52.9969639876526, 52.9772245626464, 52.9572302296226, 52.9369849795302, + 52.9164927246543, 52.8957573081327, 52.874782514921, 52.8753484940673, + 52.8754969678358, 52.8752336384789, 52.8745641635519, 52.8734941617477, + 52.8720292165553, 52.8701748779063, 52.8679366617743, 52.8685558787699, + 52.8686908924813, 52.8683487907663, 52.8675365865898, 52.8662612106245, + 52.8645295034948, 52.8623482080204, 52.8597239618267, 52.8768659830996, + 52.8933784018551, 52.9092700614482, 52.924549641305, 52.9392256562126, + 52.9533064569932, 52.9668002324032, 52.9797150120268, 53.0040521235149, + 53.0276029137632, 53.0503783678472, 53.0723892704595, 53.0936462124051, + 53.1141595970005, 53.133939646322, 53.1529964072325, 53.1991087930012, + 53.2441915135483, 53.2882590850826, 53.3313257828683, 53.3734056484002, + 53.4145124965715, 53.454659922742, 53.4938613098031, 53.5522987264306, + 53.6093131100059, 53.6649264231407, 53.7191602777988, 53.7720359473825, + 53.8235743786869, 53.8737962034961, 53.9227217498486, 53.9959969509468, + 54.067501337442, 54.1372644711006, 54.2053154466461, 54.2716829045695, + 54.3363950427143, 54.3994796266722, 54.4609639989449, 54.7571970139921, + 55.0460113389322, 55.3275978110832, 55.6021417987347, 55.8698233762712, + 56.130817491638, 56.3852941266452, 56.6334184506529, 56.8753509680541, + 57.1112476601323, 57.3412601215536, 57.5655356920045, 57.784217583293, + 57.9974450021973, 58.2053532693927, 58.4080739347323, 58.6057348890541, + 58.7984604727747, 58.9863715814237, 59.1695857682564, 59.7028917203851, + 60.2182480578803, 60.7163432006172, 61.1978357881283, 61.6633561198229, + 62.1135075181214, 62.5488676191677, 62.9699895952467, 63.3774033129259, + 63.7716164305927, 64.1531154388049, 64.5223666468, 64.8798171180752, + 65.2258955579651, 65.5610131558936, 65.8855643847536, 66.1999277598568, + 66.5044665596214, 66.7995295101024, 67.0854514353646, 67.5886907661664, + 68.0726617142777, 68.5382490193387, 68.9862916005972, 69.4175851795638, + 69.8328847382081, 70.232906824027, 70.6183317123027, 70.989805435256, + 71.3479416869242, 71.693323612126, 72.0265054871698, 72.3480142993613, + 72.658351232017, 72.957993061097, 73.2473934691287, 73.5269842817961, + 73.7971766321084, 74.0583620567415, 74.3109135288535, 74.6901736885414, + 75.0558984587555, 75.408718673833, 75.7492312127658, 76.0780010369612, + 76.3955630942643, 76.7024240987418, 76.9990641949085, 77.2859385146065, + 77.563478633935, 77.8320939372215, 78.0921728944174, 78.3440842578954, + 78.5881781841129, 78.8247872852686, 79.0542276156998, 79.2767995973644, + 79.4927888885206, 79.7024671993609, 79.9060930581195, 80.1973105767848, + 80.4813070102551, 80.758344925474, 81.0286752628363, 81.2925379334408, + 81.5501623818901, 81.8017681168137, 82.0475652111358, 82.2877547740023, + 82.5225293961366, 82.7520735702287, 82.9765640879734, 83.1961704151026, + 83.4110550458285, 83.6213738378931, 83.8272763294137, 84.0289060386336, + 84.2264007475692, 84.4198927705168, 84.6095092083201, 84.7861181750429, + 84.9603939207302, 85.1323865902055, 85.3021449486706, 85.4697164275076, + 85.6351471683084, 85.7984820651801, 85.9597648054389, 86.1190379087497, + 86.2763427647498, 86.4317196692701, 86.5852078591834, 86.736845545946, + 86.8866699478943, 87.0347173213426, 87.1810229905213, 87.325621376459, + 87.4685460247393, 87.6098296323381, 87.7495040734111, 87.8912698919761, + 88.0317922894726, 88.1710882420975, 88.309174417059, 88.446067179482, + 88.5817825991169, 88.7163364568736, 88.8497442511749, 88.9820212041282, + 89.1131822675484, 89.243242128796, 89.3722152164922, 89.5001157060407, + 89.6269575250401, 89.7527543585385, 89.8775196541416, 90.0012666270148, + 90.1240082647142, 90.2457573319464, 90.3665263751636, 90.4759250236962, + 90.5847466771721, 90.6929955017679, 90.8006756216223, 90.9077911193286, + 91.0143460364356, 91.1203443739189, 91.2257900926646, 91.3306871139266, + 91.4350393198031, 91.5388505536629, 91.6421246206006, 91.7448652878914, + 91.8470762853842, 91.9487613059568, 92.049924005911, 92.1505680054015, + 92.2506968888221, 92.3503142052078, 93.4117299533642, 97.7208993591064, + 103.126092990525, 97.930204852156, 3.97632831529613 ; + + g = + 0.85520198332573, 0.8618959555867, 0.86471323042129, 0.86658207553079, + 0.8674734980744, 0.86768805602203, 0.86792150203347, 0.86782067492822, + 0.86772834498557, 0.86733470935974, 0.86693521852935, 0.86654627230692, + 0.86614314797432, 0.8657820778877, 0.86541806950527, 0.86471439969393, + 0.86436438657914, 0.86368357226743, 0.86334538178295, 0.86267993922355, + 0.86198875798926, 0.86167768487027, 0.86101368702736, 0.86036330580854, + 0.86005319736853, 0.85941024616247, 0.85878871873853, 0.85855282528548, + 0.85798361455352, 0.85736487821661, 0.85714478357285, 0.85650720110924, + 0.85582922616095, 0.8553332906212, 0.85484756964965, 0.85437352918079, + 0.85391950276429, 0.85349615783039, 0.85310206578814, 0.85276250368435, + 0.85247429166108, 0.85259663869067, 0.8527122504225, 0.85278852161073, + 0.85279172994557, 0.85269115513219, 0.85247533288703, 0.8521516493957, + 0.85174842537039, 0.85092436300367, 0.85012450217909, 0.84938947518556, + 0.84874430178415, 0.84819333465211, 0.84771914767984, 0.84728763213177, + 0.84685591791007, 0.84661007157139, 0.84628302269707, 0.84585474165564, + 0.84532533742839, 0.84471556143497, 0.84406529546904, 0.84342894562179, + 0.84286896806154, 0.8444309684924, 0.84602956365275, 0.8477596503597, + 0.84966217089267, 0.8517408032683, 0.85397042644319, 0.85630444758411, + 0.85868184772537, 0.85894237723806, 0.85915737950727, 0.85922937970162, + 0.85907089028185, 0.85860870480495, 0.85778791180279, 0.85657119291077, + 0.85493966097678, 0.85534547199474, 0.85517074478455, 0.85449542352669, + 0.85342657124938, 0.85209461522609, 0.85064838610806, 0.8492439078252, + 0.84803434807292, 0.84903433162696, 0.85091138807774, 0.85376314057202, + 0.85745192794343, 0.86166853771847, 0.86603081024265, 0.87017337540628, + 0.87380244529579, 0.886094456314, 0.89354169582654, 0.91152210140835, + 0.92519679345458, 0.95860707992767, 0.97242010634798, 0.977276557875, + 0.97771610413647, 0.97509741142019, 0.97152354500258, 0.96551292128927, + 0.95918983311556, 0.95475212890738, 0.95001294469754, 0.94839866789859, + 0.9463217600164, 0.94519386517322, 0.94379880976933, 0.94339719971316, + 0.9426971923852, 0.94326353065644, 0.94348921079791, 0.94423326634867, + 0.94435032435586, 0.94382402540843, 0.94121330293953, 0.93659164480165, + 0.92659307510473, 0.91974420252343, 0.91021023643828, 0.90236452560264, + 0.89285656708607, 0.8818820657746, 0.86893042837382, 0.85994793046653, + 0.85024113784662, 0.84441722639755, 0.8385672550226, 0.83270794181638, + 0.82682556999258, 0.82523564275388, 0.82380571463017, 0.82248831359769, + 0.82122953300327, 0.82227367571105, 0.82324914215762, 0.82410407099471, + 0.82479190901362, 0.82601287127434, 0.8270290994746, 0.82782579989858, + 0.82839120524436, 0.8292834007568, 0.82993204300115, 0.8303371598775, + 0.83050031932483, 0.8307516739294, 0.83078404124245, 0.83060309611492, + 0.83021502140174, 0.83001153753215, 0.82963046685313, 0.82907988272651, + 0.82836809072146, 0.82787307076329, 0.82722623326179, 0.82643863438826, + 0.82552146607422, 0.82480605235273, 0.82397995816044, 0.82305704974888, + 0.82205163233757, 0.82272031541485, 0.82331711266435, 0.82385601744832, + 0.82435028062045, 0.82292953330865, 0.82150581188403, 0.82008737731681, + 0.81868257559728, 0.81732692999446, 0.81598562259314, 0.81466251619786, + 0.81336142110246, 0.81025118138758, 0.80714102191753, 0.80403542701114, + 0.80093896861184, 0.7968835276815, 0.79285513731614, 0.78886512967717, + 0.78492504519659, 0.78094704418041, 0.77707147737181, 0.77331429114457, + 0.76969111132196, 0.76621705218648, 0.76290657240025, 0.75977329153867, + 0.75682978277245, 0.75462284282681, 0.75274427277923, 0.75120542073253, + 0.75001419805637, 0.75010071758913, 0.75052775229543, 0.75128804754725, + 0.75237120705571, 0.75540961424928, 0.7588144658407, 0.76255025382398, + 0.76657915393027, 0.77176341292057, 0.77710259035216, 0.78255585071279, + 0.78808446911473, 0.79580718152512, 0.80342142186764, 0.81088447078491, + 0.81816099865651, 0.82910753737497, 0.83933898745077, 0.84886352788255, + 0.85770074682911, 0.87009116499616, 0.88095520091715, 0.89047256295832, + 0.89880935012688, 0.91008123884336, 0.91908676386791, 0.9263060407206, + 0.93211114198489, 0.93524176897401, 0.93775140999249, 0.93970912424342, + 0.94117857075765, 0.93917366167121, 0.93742675891623, 0.93594099510766, + 0.93470122951955, 0.9298453976807, 0.92363664046743, 0.91567790027176, + 0.90545353063814, 0.89786738864919, 0.88875921016234, 0.87789316250774, + 0.8650271467998, 0.86024709871415, 0.85546252442577, 0.85070924492284, + 0.84602270900261, 0.84460554310014, 0.84336013250894, 0.84228660463817, + 0.84138335663722, 0.84101776451432, 0.84074392133839, 0.84055819100351, + 0.84045665947499, 0.84133918591863, 0.84227290782188, 0.84325274036444, + 0.84427376760293, 0.84577306060275, 0.84728568170476, 0.84880767123388, + 0.85033535650329, 0.85150967332176, 0.85267995789769, 0.85384486569023, + 0.85500316200969, 0.85655939310466, 0.85809643617045, 0.85961323113898, + 0.8611088568691, 0.86238803967063, 0.86364753801492, 0.86488706021038, + 0.86610637635295, 0.86708251607939, 0.86804271365714, 0.86898696064388, + 0.86991527238397, 0.87107375934093, 0.87221041430677, 0.87332534692691, + 0.87441869503343, 0.87528684051365, 0.87613857368609, 0.87697406887549, + 0.87779350888743, 0.8788192351042, 0.87982347821405, 0.88080653879978, + 0.88176872692404, 0.88250053625554, 0.88321763999083, 0.88392025838806, + 0.88460861345162, 0.88550637066944, 0.88638415005912, 0.88724232568758, + 0.88808127023613, 0.88873479608502, 0.88937416393059, 0.88999964212772, + 0.89061149513266, 0.89138902998155, 0.89214860298452, 0.89289059092171, + 0.89361536427562, 0.89432328707831, 0.89501471680109, 0.89569000427575, + 0.8963494936374, 0.89691387206617, 0.89746529306476, 0.89800402140425, + 0.8985303163927, 0.89904443189963, 0.89954661639009, 0.90003711296983, + 0.90051615944164, 0.90099949712976, 0.90147136324247, 0.90193199677457, + 0.90238163110405, 0.90282049411927, 0.90324880835095, 0.90366679110833, + 0.90407465461858, 0.904544261362, 0.905002266153, 0.90544892048668, + 0.90588446976742, 0.90630915348776, 0.90672320540036, 0.90712685368124, + 0.9075203210836, 0.90791584480448, 0.90830123936479, 0.90867672483355, + 0.90904251588302, 0.90939882191595, 0.90974584718478, 0.91008379090379, + 0.91041284735428, 0.91079089492546, 0.91115888022349, 0.91151702790869, + 0.91186555661658, 0.91220467907853, 0.91253460223767, 0.91285552736077, + 0.91316765014676, 0.91348043601384, 0.9137844958998, 0.91408001908957, + 0.91436718933982, 0.91464618499405, 0.91491717909661, 0.91518033950579, + 0.9154358290064, 0.91573417676745, 0.91602376159097, 0.91630477135043, + 0.91657738785984, 0.91684178704125, 0.91709813909368, 0.91734660866358, + 0.91758735501712, 0.91783115415958, 0.91806716842807, 0.91829555335645, + 0.91851645939734, 0.91873003212396, 0.91893641243255, 0.91913573674491, + 0.91932813721051, 0.91959358420181, 0.91984992407577, 0.92009734469705, + 0.92033602805202, 0.92056615056189, 0.92078788338686, 0.92100139272056, + 0.92120684007354, 0.92144450279031, 0.92167301209586, 0.9218925581055, + 0.92210332582612, 0.92230549544377, 0.92249924259127, 0.92268473859601, + 0.92286215070741, 0.92315876142299, 0.92344147356691, 0.92371066267106, + 0.92396669168594, 0.92420991150277, 0.92444066143085, 0.92465926963309, + 0.92486605352259, 0.92506132012346, 0.92524536639888, 0.92541847954935, + 0.9255809372842, 0.92573300806926, 0.92587495135342, 0.92600701777712, + 0.92612944936513, 0.9262424797064, 0.92634633412325, 0.92644122983234, + 0.92652737609936, 0.92665939337085, 0.92677700588599, 0.92688065499044, + 0.92697076087047, 0.92704772357134, 0.92711192397199, 0.92716372471961, + 0.92720347112662, 0.92723149203277, 0.92724810063437, 0.92725359528235, + 0.92724826025083, 0.92723236647751, 0.92720617227667, 0.92716992402592, + 0.92712385682738, 0.9270681951437, 0.92700315340955, 0.92692893661896, + 0.92684574088857, 0.92673785065239, 0.92661795546043, 0.92648638806754, + 0.92634346596663, 0.92618949240614, 0.9260247573327, 0.92584953826402, + 0.92566410109628, 0.92546870085054, 0.92526358236207, 0.92504898091641, + 0.9248251228358, 0.92459222601937, 0.92435050044012, 0.92410014860206, + 0.92384136596014, 0.9235743413057, 0.92329925712021, 0.9230162898995, + 0.92272561045111, 0.92237973320563, 0.92202602542577, 0.92166468360499, + 0.92129589687269, 0.92091984736732, 0.9205367105824, 0.92014665568847, + 0.91974984583254, 0.91934643841793, 0.91893658536568, 0.91852043335967, + 0.91809812407672, 0.91766979440309, 0.91723557663871, 0.91679559869001, + 0.91634998425252, 0.91589885298409, 0.91544232066935, 0.91498049937636, + 0.91451349760586, 0.91402783009398, 0.91353901020371, 0.91304709305907, + 0.91255213245138, 0.91205418090055, 0.91155328971263, 0.91104950903378, + 0.91054288790089, 0.91003347428921, 0.90952131515711, 0.90900645648814, + 0.90848894333073, 0.90796881983546, 0.90744612929025, 0.90692091415362, + 0.90639321608588, 0.90586307597883, 0.9053305339836, 0.90479562953711, + 0.90425840138701, 0.90379919812875, 0.90333885458855, 0.90287738291041, + 0.90241479514152, 0.9019511032344, 0.90148631904878, 0.90102045435349, + 0.90055352082806, 0.90008553006448, 0.89961649356864, 0.89914642276181, + 0.89867532898196, 0.89820322348509, 0.89773011744644, 0.89725602196155, + 0.8967809480474, 0.89630490664343, 0.89582790861244, 0.89534996474152, + 0.89487108574286, 0.89444068502196, 0.89400946996604, 0.8935774479153, + 0.89314462616513, 0.89271101196656, 0.89227661252658, 0.89184143500858, + 0.89140548653254, 0.89096877417553, 0.89053130497182, 0.89009308591327, + 0.88965412394963, 0.88921442598867, 0.8887739988965, 0.88833284949777, + 0.88789098457587, 0.88744841087316, 0.8870051350911, 0.88656116389046, + 0.88611650389148, 0.88573820716973, 0.88535927204321, 0.88497970323419, + 0.88459950542644, 0.88421868326553, 0.88383724135928, 0.88345518427802, + 0.88307251655504, 0.88268924268692, 0.88230536713381, 0.88192089431982, + 0.88153582863329, 0.88115017442718, 0.88076393601936, 0.88037711769285, + 0.87998972369626, 0.87960175824394, 0.8792132255164, 0.87882412966053, + 0.87458118644493, 0.85432798636571, 0.81078458816782, 0.71233736257576, + 0.0011865645318794 ; +} diff --git a/Mie_LUT_Cloud.nc b/Mie_LUT_Cloud.nc @@ -1 +0,0 @@ -#$# git-wad 63c4b463b903e6415b3194d0b9c12bcf3883c393816044ad8faa948e6f078ede 62504928 -\ No newline at end of file diff --git a/README.md b/README.md @@ -1,35 +1,50 @@ # High-Tune: Mie -This library loads and manages the Mie's data - -## How to build - -This program relies on the [CMake](http://www.cmake.org) and the -[RCMake](https://gitlab.com/vaplv/rcmake/) packages to build. -It also depends on the -[RSys](https://gitlab.com/vaplv/rsys/), and -[NetCDF](https://www.unidata.ucar.edu/software/netcdf/) C libraries. It -optionally depends on [scdoc](https://sr.ht/~sircmpwn/scdoc/) which, if -available, is used to generate the man pages. - -First ensure that CMake is installed on your system. Then install the RCMake -package as well as the aforementioned prerequisites. Finally generate the -project from the `cmake/CMakeLists.txt` file by appending to the -`CMAKE_PREFIX_PATH` variable the install directories of its dependencies. The -resulting project can be edited, built, tested and installed as any CMake -project. Refer to the [CMake](https://cmake.org/documentation) for further -informations on CMake. +This C library loads the optical properties of water droplets obtained +by a Mie scattering evaluation and saved in htmie format. See `htmie.5` +for format specification. + +## Requirements + +- C compiler +- POSIX make +- pkg-config +- netCDF4 +- [RSys](https://gitlab.com/vaplv/rsys) +- [mandoc](https://mandoc.bsd.lv) + +## Installation + +Edit config.mk as needed, then run: + + make clean install ## Release notes +### Version 0.1 + +- Correction of validity range tests on loaded data: validity ranges + were incorrect for mass absorption cross sections, mass scattering + cross sections and Hengyey-Greenstein asymmetric phase function + parameters. +- Do not manage the netCDF file with git: follow its CDL version + instead. +- Write the man page directly in mdoc's roff macros, instead of using + the intermediate scdoc source. +- Replace CMake by Makefile as build system. +- Update compiler and linker flags to increase the security and + robustness of generated binaries. +- Provide a pkg-config file to link the library as an external + dependency. + ### Version 0.0.4 Use scdoc rather than asciidoc as file format for man sources. ### Version 0.0.3 -Sets the CMake minimum version to 3.1: since CMake 3.20, version 2.8 has become -obsolete. +Sets the CMake minimum version to 3.1: since CMake 3.20, version 2.8 has +become obsolete. ### Version 0.0.2 @@ -38,17 +53,18 @@ Fix compilation warnings when using the NetCDF library in version 4.4.0. ### Version 0.0.1 - Fix compilation errors when using the NetCDF library in version 4.4.0. -- Minor correction of linear interpolation: the interpolation parameter was not - correctly truncated between [0,1] in order to handle numerical inaccuracy. +- Minor correction of linear interpolation: the interpolation parameter + was not correctly truncated between [0,1] in order to handle numerical + inaccuracy. -## Copyright +## Copyrights -Copyright (C) 2018, 2020-2023 [|Méso|Star](http://www.meso-star.com) (<contact@meso-star.com>) +Copyright (C) 2018, 2020-2023 |Méso|Star> (contact@meso-star.com) Copyright (C) 2018 Centre National de la Recherche Scientifique (CNRS) -Copyright (C) 2018 Université Paul Sabatier (<contact-edstar@laplace.univ-tlse.fr>) +Copyright (C) 2018 Université Paul Sabatier ## License -HTMie is free software released under the GPL v3+ license: GNU GPL version 3 -or later. You are welcome to redistribute it under certain conditions; refer -to the COPYING file for details. +HTMie is free software released under the GPL v3+ license: GNU GPL +version 3 or later. You are welcome to redistribute it under certain +conditions; refer to the COPYING file for details. diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -1,172 +0,0 @@ -# Copyright (C) 2018, 2020-2023 |Méso|Star> (contact@meso-star.com) -# Copyright (C) 2018 CNRS -# Copyright (C) 2018 Université Paul Sabatier -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -cmake_minimum_required(VERSION 3.1) -project(htmie) -enable_testing() - -option(NO_TEST "Do not build tests" OFF) - -set(HTMIE_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../src) - -################################################################################ -# Prerequisites -################################################################################ -get_filename_component(_current_source_dir ${CMAKE_CURRENT_LIST_FILE} PATH) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${_current_source_dir}) - -find_package(RCMake 0.3 REQUIRED) -find_package(RSys 0.6 REQUIRED) -find_package(NetCDF REQUIRED) - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${RCMAKE_SOURCE_DIR}) -include(rcmake) -include(rcmake_runtime) - -include_directories( - ${NETCDF_C_INCLUDE_DIRS} - ${RSys_INCLUDE_DIR}) - -# Required by the netcdf.h header that in some versions contains C99 comments -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu89") - -if(CMAKE_COMPILER_IS_GNUCC) - set(MATH_LIB m) -endif() - -################################################################################ -# Configure and define targets -################################################################################ -set(VERSION_MAJOR 0) -set(VERSION_MINOR 0) -set(VERSION_PATCH 4) -set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) - -set(HTMIE_FILES_SRC htmie.c) -set(HTMIE_FILES_INC ) -set(HTMIE_FILES_INC_API htmie.h) -set(HTMIE_FILES_DOC README.md COPYING) - -# Prepend each file in the `HTCP_FILES_<SRC|INC>' list by `HTCP_SOURCE_DIR' -rcmake_prepend_path(HTMIE_FILES_SRC ${HTMIE_SOURCE_DIR}) -rcmake_prepend_path(HTMIE_FILES_INC ${HTMIE_SOURCE_DIR}) -rcmake_prepend_path(HTMIE_FILES_INC_API ${HTMIE_SOURCE_DIR}) -rcmake_prepend_path(HTMIE_FILES_DOC ${PROJECT_SOURCE_DIR}/../) - -add_library(htmie SHARED ${HTMIE_FILES_SRC} ${HTMIE_FILES_INC} ${HTMIE_FILES_INC_API}) -target_link_libraries(htmie RSys ${NETCDF_C_LIBRARIES} ${MATH_LIB}) - -set_target_properties(htmie PROPERTIES - DEFINE_SYMBOL HTMIE_SHARED_BUILD - VERSION ${VERSION} - SOVERSION ${VERSION_MAJOR}) - -rcmake_setup_devel(htmie HTMIE ${VERSION} high_tune/htmie_version.h) - -################################################################################ -# Man pages -################################################################################ -find_program(SCDOC NAMES scdoc) -if(NOT SCDOC) - message(WARNING - "The `scdoc' program is missing. " - "The High-Tune Mie man page cannot be generated.") -else() - set(_src ${PROJECT_SOURCE_DIR}/../doc/htmie.5.scd) - add_custom_command( - OUTPUT htmie.5 - COMMAND ${SCDOC} < ${_src} > htmie.5 - DEPENDS ${_src} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "Buid ROFF man page htmie.5" - VERBATIM) - add_custom_target(man-roff ALL DEPENDS htmie.5) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/htmie.5 DESTINATION share/man/man5) -endif() - -################################################################################ -# Test utilities -################################################################################ -if(NOT NO_TEST) - function(build_test _name) - add_executable(${_name} - ${HTMIE_SOURCE_DIR}/${_name}.c) - target_link_libraries(${_name} htmie) - endfunction() - - function(new_test _name) - build_test(${_name}) - add_test(${_name} ${_name}) - endfunction() - - new_test(test_htmie) - - find_program(_ncdump ncdump) - - if(NOT _ncdump) - message(WARNING - "The ncdump program is missing. Could not test the loading of a htmie " - "file.") - else() - build_test(test_htmie_load) - - set(TEST_FILES Mie_LUT_Cloud) - - foreach(_file IN LISTS TEST_FILES) - set(_netcdf ${PROJECT_SOURCE_DIR}/../${_file}.nc) - set(_script ${HTMIE_SOURCE_DIR}/dump_netcdf_data.sh) - set(_output_base ${CMAKE_CURRENT_BINARY_DIR}/${_file}) - add_custom_command( - OUTPUT - ${_output_base}_lambda - ${_output_base}_macs - ${_output_base}_mscs - ${_output_base}_rmod - ${_output_base}_smod - ${_output_base}_g - COMMAND sh ${_script} lambda ${_netcdf} - COMMAND sh ${_script} macs ${_netcdf} - COMMAND sh ${_script} mscs ${_netcdf} - COMMAND sh ${_script} rmod ${_netcdf} - COMMAND sh ${_script} smod ${_netcdf} - COMMAND sh ${_script} g ${_netcdf} - DEPENDS ${_script} - COMMENT "Dump data of the ${_file} NetCDF" - VERBATIM) - add_test(test_htmie_load_${_file} - test_htmie_load ${_netcdf} ${CMAKE_CURRENT_BINARY_DIR}) - add_custom_target(dump-${_file}.nc ALL DEPENDS - ${_output_base}_lambda - ${_output_base}_macs - ${_output_base}_mscs - ${_output_base}_rmod - ${_output_base}_smod - ${_output_base}_g) - endforeach() - endif() -endif() - -################################################################################ -# Define output & install directories -################################################################################ -install(TARGETS htmie - ARCHIVE DESTINATION bin - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin) -install(FILES ${HTMIE_FILES_INC_API} DESTINATION include/high_tune) -install(FILES ${HTMIE_FILES_DOC} DESTINATION share/doc/htmie) - diff --git a/cmake/FindNetCDF.cmake b/cmake/FindNetCDF.cmake @@ -1,119 +0,0 @@ -# - Find NetCDF -# Find the native NetCDF includes and library -# -# NETCDF_INCLUDE_DIR - user modifiable choice of where netcdf headers are -# NETCDF_LIBRARY - user modifiable choice of where netcdf libraries are -# -# Your package can require certain interfaces to be FOUND by setting these -# -# NETCDF_CXX - require the C++ interface and link the C++ library -# NETCDF_F77 - require the F77 interface and link the fortran library -# NETCDF_F90 - require the F90 interface and link the fortran library -# -# Or equivalently by calling FindNetCDF with a COMPONENTS argument containing one or -# more of "CXX;F77;F90". -# -# When interfaces are requested the user has access to interface specific hints: -# -# NETCDF_${LANG}_INCLUDE_DIR - where to search for interface header files -# NETCDF_${LANG}_LIBRARY - where to search for interface libraries -# -# This module returns these variables for the rest of the project to use. -# -# NETCDF_FOUND - True if NetCDF found including required interfaces (see below) -# NETCDF_LIBRARIES - All netcdf related libraries. -# NETCDF_INCLUDE_DIRS - All directories to include. -# NETCDF_HAS_INTERFACES - Whether requested interfaces were found or not. -# NETCDF_${LANG}_INCLUDE_DIRS/NETCDF_${LANG}_LIBRARIES - C/C++/F70/F90 only interface -# -# Normal usage would be: -# set (NETCDF_F90 "YES") -# find_package (NetCDF REQUIRED) -# target_link_libraries (uses_everthing ${NETCDF_LIBRARIES}) -# target_link_libraries (only_uses_f90 ${NETCDF_F90_LIBRARIES}) - -#search starting from user editable cache var -if (NETCDF_INCLUDE_DIR AND NETCDF_LIBRARY) - # Already in cache, be silent - set (NETCDF_FIND_QUIETLY TRUE) -endif () - -set(USE_DEFAULT_PATHS "NO_DEFAULT_PATH") -if(NETCDF_USE_DEFAULT_PATHS) - set(USE_DEFAULT_PATHS "") -endif() - -find_path (NETCDF_INCLUDE_DIR netcdf.h - PATHS "${NETCDF_DIR}/include") -mark_as_advanced (NETCDF_INCLUDE_DIR) -set (NETCDF_C_INCLUDE_DIRS ${NETCDF_INCLUDE_DIR}) - -find_library (NETCDF_LIBRARY NAMES netcdf - PATHS "${NETCDF_DIR}/lib" - HINTS "${NETCDF_INCLUDE_DIR}/../lib") -mark_as_advanced (NETCDF_LIBRARY) - -set (NETCDF_C_LIBRARIES ${NETCDF_LIBRARY}) - -#start finding requested language components -set (NetCDF_libs "") -set (NetCDF_includes "${NETCDF_INCLUDE_DIR}") - -get_filename_component (NetCDF_lib_dirs "${NETCDF_LIBRARY}" PATH) -set (NETCDF_HAS_INTERFACES "YES") # will be set to NO if we're missing any interfaces - -macro (NetCDF_check_interface lang header libs) - if (NETCDF_${lang}) - #search starting from user modifiable cache var - find_path (NETCDF_${lang}_INCLUDE_DIR NAMES ${header} - HINTS "${NETCDF_INCLUDE_DIR}" - HINTS "${NETCDF_${lang}_ROOT}/include" - ${USE_DEFAULT_PATHS}) - - find_library (NETCDF_${lang}_LIBRARY NAMES ${libs} - HINTS "${NetCDF_lib_dirs}" - HINTS "${NETCDF_${lang}_ROOT}/lib" - ${USE_DEFAULT_PATHS}) - - mark_as_advanced (NETCDF_${lang}_INCLUDE_DIR NETCDF_${lang}_LIBRARY) - - #export to internal varS that rest of project can use directly - set (NETCDF_${lang}_LIBRARIES ${NETCDF_${lang}_LIBRARY}) - set (NETCDF_${lang}_INCLUDE_DIRS ${NETCDF_${lang}_INCLUDE_DIR}) - - if (NETCDF_${lang}_INCLUDE_DIR AND NETCDF_${lang}_LIBRARY) - list (APPEND NetCDF_libs ${NETCDF_${lang}_LIBRARY}) - list (APPEND NetCDF_includes ${NETCDF_${lang}_INCLUDE_DIR}) - else () - set (NETCDF_HAS_INTERFACES "NO") - message (STATUS "Failed to find NetCDF interface for ${lang}") - endif () - endif () -endmacro () - -list (FIND NetCDF_FIND_COMPONENTS "CXX" _nextcomp) -if (_nextcomp GREATER -1) - set (NETCDF_CXX 1) -endif () -list (FIND NetCDF_FIND_COMPONENTS "F77" _nextcomp) -if (_nextcomp GREATER -1) - set (NETCDF_F77 1) -endif () -list (FIND NetCDF_FIND_COMPONENTS "F90" _nextcomp) -if (_nextcomp GREATER -1) - set (NETCDF_F90 1) -endif () -NetCDF_check_interface (CXX netcdfcpp.h netcdf_c++) -NetCDF_check_interface (F77 netcdf.inc netcdff) -NetCDF_check_interface (F90 netcdf.mod netcdff) - -#export accumulated results to internal varS that rest of project can depend on -list (APPEND NetCDF_libs "${NETCDF_C_LIBRARIES}") -set (NETCDF_LIBRARIES ${NetCDF_libs}) -set (NETCDF_INCLUDE_DIRS ${NetCDF_includes}) - -# handle the QUIETLY and REQUIRED arguments and set NETCDF_FOUND to TRUE if -# all listed variables are TRUE -include (FindPackageHandleStandardArgs) -find_package_handle_standard_args (NetCDF - DEFAULT_MSG NETCDF_LIBRARIES NETCDF_INCLUDE_DIRS NETCDF_HAS_INTERFACES) diff --git a/config.mk b/config.mk @@ -0,0 +1,84 @@ +VERSION = 0.1.0 +PREFIX = /usr/local + +LIB_TYPE = SHARED +#LIB_TYPE = STATIC + +BUILD_TYPE = RELEASE +#BUILD_TYPE = DEBUG + +################################################################################ +# Tools +################################################################################ +AR = ar +CC = cc +LD = ld +OBJCOPY = objcopy +PKG_CONFIG = pkg-config +RANLIB = ranlib + +################################################################################ +# Dependencies +################################################################################ +PCFLAGS_SHARED = +PCFLAGS_STATIC = --static +PCFLAGS = $(PCFLAGS_$(LIB_TYPE)) + +NETCDF_VERSION = 4 +NETCDF_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags netcdf) +NETCDF_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs netcdf) + +RSYS_VERSION = 0.14 +RSYS_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags rsys) +RSYS_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs rsys) + +DPDC_CFLAGS = $(NETCDF_CFLAGS) $(RSYS_CFLAGS) +DPDC_LIBS = $(NETCDF_LIBS) $(RSYS_LIBS) + +################################################################################ +# Compilation options +################################################################################ +WFLAGS =\ + -Wall\ + -Wcast-align\ + -Wconversion\ + -Wextra\ + -Wmissing-declarations\ + -Wmissing-prototypes\ + -Wshadow + +CFLAGS_HARDENED =\ + -D_FORTIFY_SOURCES=2\ + -fcf-protection=full\ + -fstack-clash-protection\ + -fstack-protector-strong + +CFLAGS_COMMON =\ + -std=c89\ + -pedantic\ + -fvisibility=hidden\ + -fstrict-aliasing\ + $(CFLAGS_HARDENED)\ + $(WFLAGS) + +CFLAGS_DEBUG = -g $(CFLAGS_COMMON) +CFLAGS_RELEASE = -O2 -DNDEBUG $(CFLAGS_COMMON) +CFLAGS = $(CFLAGS_$(BUILD_TYPE)) + +CFLAGS_SO = $(CFLAGS) -fPIC +CFLAGS_EXE = $(CFLAGS) -fPIE + +################################################################################ +# Linker options +################################################################################ +LDFLAGS_HARDENED = -Wl,-z,relro,-z,now +LDFLAGS_DEBUG = $(LDFLAGS_HARDENED) +LDFLAGS_RELEASE = -s $(LDFLAGS_HARDENED) +LDFLAGS = $(LDFLAGS_$(BUILD_TYPE)) + +LDFLAGS_SO = $(LDFLAGS) -shared -Wl,--no-undefined +LDFLAGS_EXE = $(LDFLAGS) -pie + +OCPFLAGS_DEBUG = --localize-hidden +OCPFLAGS_RELEASE = --localize-hidden --strip-unneeded +OCPFLAGS = $(OCPFLAGS_$(BUILD_TYPE)) diff --git a/doc/htmie.5.scd b/doc/htmie.5.scd @@ -1,54 +0,0 @@ -htmie(5) - -; Copyright (C) 2018, 2020-2023 |Méso|Star> (contact@meso-star.com) -; Copyright (C) 2018 CNRS -; Copyright (C) 2018 Université Paul Sabatier -; -; This program is free software: you can redistribute it and/or modify -; it under the terms of the GNU General Public License as published by -; the Free Software Foundation, either version 3 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program. If not, see <http://www.gnu.org/licenses/>. - -# NAME - -htmie - High-Tune: Mie's data file format - -# DESCRIPTION - -*htmie* is the file format used by *htrdr*(1) to describe the optical -properties of water droplets obtained by a Mie code. This format relies on the -NetCDF data format [1]. To be a valid *htmie* file, the NetCDF file must -define the following variables: - -*lambda*++ - One dimensional array of floating point data that lists the wavelengths -in nanometers for which the subsequent data are defined. - -*macs*++ - One dimensional array of massic absorption cross-sections in kg of liquid -water in suspension. - -*mscs*++ - One dimensional array of massic scattering cross-sections in kg of liquid -water in suspension. - -*g*++ - One dimensional array of asymmetry parameters of the equivalent -Henyey-Greenstein phase function. - -# NOTES - -. Network Common Data Form - <https://www.unidata.ucar.edu/software/netcdf/> - -# SEE ALSO - -*htrdr*(1) - diff --git a/dummy.cdl b/dummy.cdl @@ -0,0 +1,27 @@ +netcdf Mie_LUT_Cloud { +dimensions: + lambda = 3 ; + distribution = UNLIMITED ; // (1 currently) +variables: + double lambda(lambda) ; + lambda:long_name = "Wavelength" ; + lambda:units = "nanometers" ; + double mscs(distribution, lambda) ; + mscs:long_name = "Massic scattering cross section" ; + mscs:units = "m^2/kg" ; + double macs(distribution, lambda) ; + macs:long_name = "Massic absorption cross section" ; + macs:units = "m^2/kg" ; + double g(distribution, lambda) ; + g:long_name = "Asymmetry parameter" ; + g:units = "-" ; +data: + + lambda = 200, 225, 250 ; + + mscs = 0, 148.583778410196, 148.848607519154 ; + + macs = 0, 0.00376469098500625, 0.00235556776982531 ; + + g = -1, 1, 0 ; +} diff --git a/htmie.5 b/htmie.5 @@ -0,0 +1,58 @@ +.\" Copyright (C) 2018, 2020-2023 |Méso|Star> (contact@meso-star.com) +.\" Copyright (C) 2018 Centre National de la Recherche Scientifique +.\" Copyright (C) 2018 Université Paul Sabatier +.\" +.\" This program is free software: you can redistribute it and/or modify +.\" it under the terms of the GNU General Public License as published by +.\" the Free Software Foundation, either version 3 of the License, or +.\" (at your option) any later version. +.\" +.\" This program is distributed in the hope that it will be useful, +.\" but WITHOUT ANY WARRANTY; without even the implied warranty of +.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +.\" GNU General Public License for more details. +.\" +.\" You should have received a copy of the GNU General Public License +.\" along with this program. If not, see <http://www.gnu.org/licenses/>. +.Dd September 8, 2023 +.Dt HTMIE 5 +.Os +.Sh NAME +.Nm htmie +.Nd High-Tune: Mie +.Sh DESCRIPTION +.Nm +is a netCDF file format for storing the optical properties of water droplets +obtained by Mie scattering evaluation. +A +.Nm +netCDF file must define the following variables: +.Bl -hang +.It Va lambda +One-dimensional array of floating-point data that lists the wavelengths in +nanometers for which the following data are defined. +.It Va macs +One dimensional array of massic absorption cross-sections in kg of liquid +water in suspension. +.It Va mscs +One-dimensional table of mass diffusion cross-sections in kg of suspended +liquid water. +.It Va g +One-dimensional table of asymmetry parameters of the Henyey-Greenstein +equivalent phase function. +.El +.Sh SEE ALSO +.Xr htrdr 1 +.Sh STANDARDS +.Rs +.%A Edward Hartnett +.%D March 2011 +.%R ESDS-RFC-022v1 +.%T netCDF4/HDF5 File Format +.Re +.Sh HISTORY +The +.Nm +format was first developed for the +.Xr htrdr 1 +program. diff --git a/htmie.pc.in b/htmie.pc.in @@ -0,0 +1,11 @@ +prefix=@PREFIX@ +includedir=${prefix}/include +libdir=${prefix}/lib + +Requires: rsys >= @RSYS_VERSION@ +Requires.private: netcdf >= @NETCDF_VERSION@ +Name: htmie +Description: High-Tune Mie +Version: @VERSION@ +Libs: -L${libdir} -lhtmie +CFlags: -I${includedir} diff --git a/make.sh b/make.sh @@ -0,0 +1,72 @@ +#!/bin/sh + +# Copyright (C) 2018, 2020-2023 |Méso|Star> (contact@meso-star.com) +# Copyright (C) 2018 Centre National de la Recherche Scientifique +# Copyright (C) 2018 Université Paul Sabatier +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +set -e + +config_test() +{ + for i in "$@"; do + test=$(basename "${i}" ".c") + test_list="${test_list} ${test}" + printf "%s: %s\n" "${test}" "src/${test}.o" + done + printf "test_bin: %s\n" "${test_list}" +} + +check() +{ + name="$1" + prog="$2" + shift 2 + + printf "%s " "${name}" + if ./"${prog}" "$@" > /dev/null 2>&1; then + printf "\033[1;32mOK\033[m\n" + else + printf "\033[1;31mError\033[m\n" + fi 2> /dev/null +} + +clean_test() +{ + for i in "$@"; do + rm -f "$(basename "${i}" ".c")" + done +} + +install() +{ + prefix=$1 + shift 1 + + mkdir -p "${prefix}" + + for i in "$@"; do + dst="${prefix}/${i##*/}" + + if cmp -s "${i}" "${dst}"; then + printf "Up to date %s\n" "${dst}" + else + printf "Installing %s\n" "${dst}" + cp "${i}" "${prefix}" + fi + done +} + +"$@" diff --git a/src/dump_netcdf_data.sh b/src/dump_netcdf_data.sh @@ -1,7 +1,7 @@ #!/bin/sh -e # Copyright (C) 2018, 2020-2023 |Méso|Star> (contact@meso-star.com) -# Copyright (C) 2018 CNRS +# Copyright (C) 2018 Centre National de la Recherche Scientifique # Copyright (C) 2018 Université Paul Sabatier # # This program is free software: you can redistribute it and/or modify @@ -18,22 +18,25 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. */ if [ $# -lt 2 ]; then - echo "Usage: $0 VAR-NAME MIE-NETCDF " - exit 0 + printf "usage: %s variable netcdf\n" "${0##*/}" >&2 + exit 1 fi if [ ! -f "$2" ]; then - echo "\"$2\" is not a valid file." - exit 0 + printf "\"%s\" is not a valid file\n" "$2" + exit 1 fi name=${2##*/} name=${name%.*} +blanks="[[:space:]]\{0,\}" + ncdump -v "$1" "$2" \ - | sed -n "/^ *$1 *=/,\$p" \ - | sed "s/^ *$1 *= *//g" \ - | sed 's/[;} ]//g' \ - | sed 's/,/\n/g' \ - | sed '/^ *$/d' > "${name}_${1}" + | sed -n "/^${blanks}data:${blanks}/,\$p" \ + | sed -n "/^${blanks}$1${blanks}=/,\$p" \ + | sed "s/^${blanks}$1${blanks}=${blanks}//g" \ + | sed "s/[;} ]//g" \ + | sed "s/,/\n/g" \ + | sed "/^${blanks}$/d" diff --git a/src/htmie.c b/src/htmie.c @@ -1,5 +1,5 @@ /* Copyright (C) 2018, 2020-2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2018 CNRS + * Copyright (C) 2018 Centre National de la Recherche Scientifique * Copyright (C) 2018 Université Paul Sabatier * * This program is free software: you can redistribute it and/or modify @@ -603,7 +603,7 @@ htmie_load(struct htmie* htmie, const char* path) { int err_nc = NC_NOERR; int nc = INVALID_NC_ID; - double range[2]; + double range[2] = {DBL_MAX, -DBL_MAX}; /* Validity range of loaded data */ res_T res = RES_OK; if(!htmie || !path) { @@ -618,17 +618,22 @@ htmie_load(struct htmie* htmie, const char* path) goto error; } - /* Define the validity range for the loaded data */ - range[0] = DBL_EPSILON; - range[1] = DBL_MAX; - #define CALL(Func) { res = Func; if(res != RES_OK) goto error; } (void)0 + + range[0] = DBL_EPSILON; range[1] = DBL_MAX; CALL(load_wavelengths(htmie, nc, range)); + + range[0] = 0; range[1] = DBL_MAX; CALL(load_distrib_x_lambda_array (htmie, nc, "macs", range, &htmie->xsections_absorption)); + + range[0] = 0; range[1] = DBL_MAX; CALL(load_distrib_x_lambda_array (htmie, nc, "mscs", range, &htmie->xsections_scattering)); + + range[0] = -1; range[1] = 1; CALL(load_distrib_x_lambda_array(htmie, nc, "g", range, &htmie->g)); + #undef CALL exit: diff --git a/src/htmie.h b/src/htmie.h @@ -1,5 +1,5 @@ /* Copyright (C) 2018, 2020-2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2018 CNRS + * Copyright (C) 2018 Centre National de la Recherche Scientifique * Copyright (C) 2018 Université Paul Sabatier * * This program is free software: you can redistribute it and/or modify diff --git a/src/test_htmie.c b/src/test_htmie.c @@ -1,5 +1,5 @@ /* Copyright (C) 2018, 2020-2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2018 CNRS + * Copyright (C) 2018 Centre National de la Recherche Scientifique * Copyright (C) 2018 Université Paul Sabatier * * This program is free software: you can redistribute it and/or modify diff --git a/src/test_htmie_load.c b/src/test_htmie_load.c @@ -1,5 +1,5 @@ /* Copyright (C) 2018, 2020-2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2018 CNRS + * Copyright (C) 2018 Centre National de la Recherche Scientifique * Copyright (C) 2018 Université Paul Sabatier * * This program is free software: you can redistribute it and/or modify @@ -279,7 +279,6 @@ main(int argc, char** argv) char* p = NULL; FILE* fp = NULL; struct htmie* htmie = NULL; - double rmod, smod; size_t i; if(argc < 3) { @@ -299,12 +298,12 @@ main(int argc, char** argv) CHK(htmie_load(htmie, filename) == RES_OK); p = strrchr(filename, '/'); - if(p) base = p+1; + base = p ? p+1 : filename; p = strrchr(base, '.'); if(p) *p = '\0'; /* Check the wavelengths list */ - CHK((size_t)snprintf(buf, sizeof(buf), "%s/%s_lambda", path, base)<sizeof(buf)); + CHK((size_t)snprintf(buf, sizeof(buf), "%s/%s.lambda", path, base)<sizeof(buf)); CHK(fp = fopen(buf, "r")); FOR_EACH(i, 0, htmie_get_wavelengths_count(htmie)) { double lambda; @@ -314,22 +313,8 @@ main(int argc, char** argv) CHK(fscanf(fp, "%*g") == EOF); CHK(fclose(fp) == 0); - /* Read rmod */ - CHK((size_t)snprintf(buf, sizeof(buf), "%s/%s_rmod", path, base)<sizeof(buf)); - CHK(fp = fopen(buf, "r")); - CHK(fscanf(fp, "%lg", &rmod) == 1); - CHK(fscanf(fp, "%*g") == EOF); - CHK(fclose(fp) == 0); - - /* Read smod */ - CHK((size_t)snprintf(buf, sizeof(buf), "%s/%s_smod", path, base)<sizeof(buf)); - CHK(fp = fopen(buf, "r")); - CHK(fscanf(fp, "%lg", &smod) == 1); - CHK(fscanf(fp, "%*g") == EOF); - CHK(fclose(fp) == 0); - /* Check absorption cross sections */ - CHK((size_t)snprintf(buf, sizeof(buf), "%s/%s_macs", path, base)<sizeof(buf)); + CHK((size_t)snprintf(buf, sizeof(buf), "%s/%s.macs", path, base)<sizeof(buf)); CHK(fp = fopen(buf, "r")); FOR_EACH(i, 0, htmie_get_wavelengths_count(htmie)) { const double Cabs = htmie_get_xsections_absorption(htmie)[i]; @@ -341,7 +326,7 @@ main(int argc, char** argv) CHK(fclose(fp) == 0); /* Check scattering cross sections */ - CHK((size_t)snprintf(buf, sizeof(buf), "%s/%s_mscs", path, base)<sizeof(buf)); + CHK((size_t)snprintf(buf, sizeof(buf), "%s/%s.mscs", path, base)<sizeof(buf)); CHK(fp = fopen(buf, "r")); FOR_EACH(i, 0, htmie_get_wavelengths_count(htmie)) { const double Csca = htmie_get_xsections_scattering(htmie)[i]; @@ -353,7 +338,7 @@ main(int argc, char** argv) CHK(fclose(fp) == 0); /* Check scattering asymmetry parameter */ - CHK((size_t)snprintf(buf, sizeof(buf), "%s/%s_g", path, base)<sizeof(buf)); + CHK((size_t)snprintf(buf, sizeof(buf), "%s/%s.g", path, base)<sizeof(buf)); CHK(fp = fopen(buf, "r")); FOR_EACH(i, 0, htmie_get_wavelengths_count(htmie)) { double g; @@ -363,7 +348,6 @@ main(int argc, char** argv) CHK(fscanf(fp, "%*g") == EOF); CHK(fclose(fp) == 0); - test_fetch(htmie); test_bounds(htmie); test_avg(htmie); diff --git a/src/test_htmie_utils.h b/src/test_htmie_utils.h @@ -1,5 +1,5 @@ /* Copyright (C) 2018, 2020-2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2018 CNRS + * Copyright (C) 2018 Centre National de la Recherche Scientifique * Copyright (C) 2018 Université Paul Sabatier * * This program is free software: you can redistribute it and/or modify