From 9b1f05da31981d1e398e9a4f00c7079abadacc6c Mon Sep 17 00:00:00 2001 From: webisu Date: Mon, 16 Sep 2024 11:35:25 -0400 Subject: [PATCH 1/4] fix shared libs, no CALLABLE_WGRIB2, wgrib2 utility calls wgrib2(..) --- CMakeLists.txt | 17 +- proj.h | 355 ------------------------ tests/CMakeLists.txt | 11 + tests/test_ftn_api.sh | 15 + tests/test_lib.sh | 15 + tests/test_shared_lib.sh | 15 + wgrib2/CMakeLists.txt | 48 ++-- wgrib2/fatal_error.c | 12 +- wgrib2/ftn_api/CMakeLists.txt | 15 +- wgrib2/gctpc/source/CMakeLists.txt | 11 + {include => wgrib2/gctpc/source}/proj.h | 0 wgrib2/wgrib2.c | 28 +- wgrib2/wgrib2_api.c | 2 - wgrib2/wgrib2_main.c | 27 ++ 14 files changed, 168 insertions(+), 403 deletions(-) delete mode 100644 proj.h create mode 100755 tests/test_ftn_api.sh create mode 100755 tests/test_lib.sh create mode 100755 tests/test_shared_lib.sh rename {include => wgrib2/gctpc/source}/proj.h (100%) create mode 100644 wgrib2/wgrib2_main.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 177abeae..cfa9e578 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,11 +32,16 @@ option(FTP_TEST_FILES "Fetch and test with files on FTP site." OFF) option(FTP_LARGE_TEST_FILES "Fetch and test with very large files on FTP site." OFF) option(FTP_EXTRA_TEST_FILES "Fetch even more large files from FTP and test them." OFF) # MAKE_FTN_API should only be on when building library -option(MAKE_FTN_API "add ftn api?" off) +option(MAKE_FTN_API "add ftn api?" on) option(DISABLE_STAT "disable posix feature" off) set(BUILD_COMMENTS "stock build") + option(BUILD_LIB "Build wgrib2 library?" on) -option(BUILD_SHARED_LIB "Build shared library?" off) +# if BUILD_LIB, then code is compiled as relocatable +option(BUILD_SHARED_LIB "Build shared library?" on) +# To create libwgrib2.so for python, you have to build with BUILD_SHARED_LIB off +# and manually create libwgrib2.so from the needed *.a files + option(BUILD_WGRIB "Build wgrib code?" off) # Developers can use this option to specify a local directory which @@ -84,6 +89,10 @@ if(USE_G2CLIB) endif() endif() +if (BUILD_SHARED_LIB AND NOT BUILD_LIB) + message(FATAL_ERROR "BUILD_SHARED_LIB is on but BUILD_LIB is off") +endif() + # If user wants to use NCEPLIBS-ip, find it and the sp library. message(STATUS "Checking if the user want to use NCEPLIBS-ip...") if(USE_IPOLATES) @@ -101,6 +110,10 @@ if(USE_OPENJPEG AND USE_JASPER) message(FATAL_ERROR "USE_OPENJPEG OR USE_JASPER, not both") endif() + + + + message(STATUS "Checking if the user wants to use Jasper...") if(USE_JASPER) list(APPEND definitions_list -DUSE_JASPER) diff --git a/proj.h b/proj.h deleted file mode 100644 index eb49170d..00000000 --- a/proj.h +++ /dev/null @@ -1,355 +0,0 @@ -/* Projection codes - - - 0 = Geographic - 1 = Universal Transverse Mercator (UTM) - 2 = State Plane Coordinates - 3 = Albers Conical Equal Area - 4 = Lambert Conformal Conic - 5 = Mercator - 6 = Polar Stereographic - 7 = Polyconic - 8 = Equidistant Conic - 9 = Transverse Mercator - 10 = Stereographic - 11 = Lambert Azimuthal Equal Area - 12 = Azimuthal Equidistant - 13 = Gnomonic - 14 = Orthographic - 15 = General Vertical Near-Side Perspective - 16 = Sinusiodal - 17 = Equirectangular - 18 = Miller Cylindrical - 19 = Van der Grinten - 20 = (Hotine) Oblique Mercator - 21 = Robinson - 22 = Space Oblique Mercator (SOM) - 23 = Alaska Conformal - 24 = Interrupted Goode Homolosine - 25 = Mollweide - 26 = Interrupted Mollweide - 27 = Hammer - 28 = Wagner IV - 29 = Wagner VII - 30 = Oblated Equal Area - 99 = User defined -*/ - -/* Define projection codes */ -#define GEO 0 -#define UTM 1 -#define SPCS 2 -#define ALBERS 3 -#define LAMCC 4 -#define MERCAT 5 -#define PS 6 -#define POLYC 7 -#define EQUIDC 8 -#define TM 9 -#define STEREO 10 -#define LAMAZ 11 -#define AZMEQD 12 -#define GNOMON 13 -#define ORTHO 14 -#define GVNSP 15 -#define SNSOID 16 -#define EQRECT 17 -#define MILLER 18 -#define VGRINT 19 -#define HOM 20 -#define ROBIN 21 -#define SOM 22 -#define ALASKA 23 -#define GOOD 24 -#define MOLL 25 -#define IMOLL 26 -#define HAMMER 27 -#define WAGIV 28 -#define WAGVII 29 -#define OBEQA 30 -#define USDEF 99 - -/* Define unit code numbers to their names */ - -#define RADIAN 0 /* Radians */ -#define FEET 1 /* Feed */ -#define METER 2 /* Meters */ -#define SECOND 3 /* Seconds */ -#define DEGREE 4 /* Decimal degrees */ -#define INT_FEET 5 /* International Feet */ - -/* The STPLN_TABLE unit value is specifically used for State Plane -- if units - equals STPLN_TABLE and Datum is NAD83--actual units are retrieved from - a table according to the zone. If Datum is NAD27--actual units will be feet. - An error will occur with this unit if the projection is not State Plane. */ - -#define STPLN_TABLE 6 - -/* General code numbers */ - -#define IN_BREAK -2 /* Return status if the interupted projection - point lies in the break area */ -#define COEFCT 15 /* projection coefficient count */ -#define PROJCT 30 /* projection count */ -#define SPHDCT 31 /* spheroid count */ - -#define MAXPROJ 31 /* Maximum projection number */ -#define MAXUNIT 5 /* Maximum unit code number */ -#define GEO_TERM 0 /* Array index for print-to-term flag */ -#define GEO_FILE 1 /* Array index for print-to-file flag */ -#define GEO_TRUE 1 /* True value for geometric true/false flags */ -#define GEO_FALSE -1 /* False val for geometric true/false flags */ - -/* GCTP Function prototypes */ - -long alberforint(double r_maj, double r_min, double lat1, double lat2, - double lon0, double lat0, double false_east, double false_north); -long alberfor(double lon, double lat, double *x, double *y); -long alberinvint( double r_maj, double r_min, double lat1, double lat2, - double lon0, double lat0, double false_east, double false_north); -long alberinv( double x, double y, double *lon, double *lat); -long alconforint( double r_maj, double r_min, double false_east, - double false_north); -long alconfor(double lon, double lat, double *x, double *y); -long alconinvint( double r_maj, double r_min, double false_east, - double false_north); -long alconinv( double x, double y, double *lon, double *lat); -long azimforint( double r_maj, double center_lon, double center_lat, - double false_east, double false_north); -long azimfor( double lon, double lat, double *x, double *y); -long aziminvint( double r_maj, double center_lon, double center_lat, - double false_east, double false_north); -long aziminv( double x, double y, double *lon, double *lat); - -/* rename functions in gctpc */ - -void gctpc_sincos( double val, double *sin_val, double *cos_val); -#define sincos(a,b,c) gctpc_sincos(a,b,c) - -int gctpc_sign(double x); -#define sign(x) gctpc_sign(x) - - - -double asinz (double con); -double msfnz (double eccent, double sinphi, double cosphi); -double qsfnz (double eccent, double sinphi, double cosphi); -double phi1z (double eccent, double qs, long *flag); -double phi2z(double eccent, double ts, long *flag); -double phi3z(double ml, double e0, double e1, double e2, double e3, - long *flag); -double phi4z (double eccent, double e0, double e1, double e2, double e3, - double a, double b, double *c, double *phi); -double pakcz(double pak); -double pakr2dm(double pak); -double tsfnz(double eccent, double phi, double sinphi); -int sign(double x); -double adjust_lon(double x); -double e0fn(double x); -double e1fn(double x); -double e2fn(double x); -double e3fn(double x); -double e4fn(double x); -double mlfn(double e0,double e1,double e2,double e3,double phi); -long calc_utm_zone(double lon); -/* End of functions residing in cproj.h */ - -long eqconforint(double r_maj, double r_min, double lat1, double lat2, - double center_lon, double center_lat, double false_east, - double false_north, - long mode); -long eqconfor(double lon, double lat, double *x, double *y); -long eqconinvint(double r_maj, double r_min, double lat1, double lat2, - double center_lon, double center_lat, double false_east, - double false_north, long mode); -long eqconinv(double x, double y, double *lon, double *lat); -long equiforint(double r_maj, double center_lon, double lat1, - double false_east, double false_north); -long equifor(double lon, double lat, double *x, double *y); -long equiinvint(double r_maj, double center_lon, double lat1, - double false_east, double false_north); -long equiinv(double x, double y, double *lon, double *lat); -void for_init(long outsys, long outzone, double *outparm, long outspheroid, - char *fn27, char *fn83, long *iflg, long (*for_trans[])()); -void gctp(double *incoor, long *insys, long *inzone, double *inparm, - long *inunit, long *inspheroid, long *ipr, char *efile, long *jpr, - char *pfile, double *outcoor, long *outsys, long *outzone, - double *outparm, long *outunit, long *outspheroid, char fn27[], - char fn83[], long *iflg); -long gnomforint(double r, double center_long, double center_lat, - double false_east, double false_north); -long gnomfor(double lon, double lat, double *x, double *y); -long gnominvint(double r, double center_long, double center_lat, - double false_east, double false_north); -long gnominv(double x, double y, double *lon, double *lat); -long goodforint(double r); -long goodfor(double lon, double lat, double *x, double *y); -long goodinvint(double r); -long goodinv(double x, double y, double *lon, double *lat); -long gvnspforint(double r, double h, double center_long, double center_lat, - double false_east, double false_north); -long gvnspfor(double lon, double lat, double *x, double *y); -long gvnspinvint(double r, double h, double center_long, double center_lat, - double false_east, double false_north); -long gvnspinv(double x, double y, double *lon, double *lat); -long hamforint(double r, double center_long, double false_east, - double false_north); -long hamfor(double lon, double lat, double *x, double *y); -long haminvint(double r, double center_long, double false_east, - double false_north); -long haminv(double x, double y, double *lon, double *lat); -long imolwforint(double r); -long imolwfor(double lon, double lat, double *x, double *y); -long imolwinvint(double r); -long imolwinv(double x, double y, double *lon, double *lat); -void inv_init(long insys, long inzone, double *inparm, long inspheroid, - char *fn27, char *fn83, long *iflg, long (*inv_trans[])()); -long lamazforint(double r, double center_long, double center_lat, - double false_east, double false_north); -long lamazfor(double lon, double lat, double *x, double *y); -long lamazinvint(double r, double center_long, double center_lat, - double false_east, double false_north); -long lamazinv(double x, double y, double *lon, double *lat); -long lamccforint(double r_maj, double r_min, double lat1, double lat2, - double c_lon, double c_lat, double false_east, double false_north); -long lamccfor(double lon, double lat, double *x, double *y); -long lamccinvint(double r_maj, double r_min, double lat1, double lat2, - double c_lon, double c_lat, double false_east, double false_north); -long lamccinv(double x, double y, double *lon, double *lat); -long merforint(double r_maj, double r_min, double center_lon, double center_lat, - double false_east, double false_north); -long merfor(double lon, double lat, double *x, double *y); -long merinvint(double r_maj, double r_min, double center_lon, double center_lat, - double false_east, double false_north); -long merinv(double x, double y, double *lon, double *lat); -long millforint(double r, double center_long, double false_east, - double false_north); -long millfor(double lon, double lat, double *x, double *y); -long millinvint(double r, double center_long, double false_east, - double false_north); -long millinv(double x, double y, double *lon, double *lat); -long molwforint(double r, double center_long, double false_east, - double false_north); -long molwfor(double lon, double lat, double *x, double *y); -long molwinvint(double r, double center_long, double false_east, - double false_north); -long molwinv(double x, double y, double *lon, double *lat); -long obleqforint(double r, double center_long, double center_lat, - double shape_m, double shape_n, double angle, double false_east, - double false_north); -long obleqfor(double lon, double lat, double *x, double *y); -long obleqinvint(double r, double center_long, double center_lat, - double shape_m, double shape_n, double angle, double false_east, - double false_north); -long omerforint(double r_maj, double r_min, double scale_fact, - double azimuth, double lon_orig, double lat_orig, double false_east, - double false_north, double lon1, double lat1, double lon2, double lat2, - long mode); -long omerfor(double lon, double lat, double *x, double *y); -long omerinvint(double r_maj, double r_min, double scale_fact, double azimuth, - double lon_orig, double lat_orig, double false_east, double false_north, - double lon1, double lat1, double lon2, double lat2, long mode); -long omerinv(double x, double y, double *lon, double *lat); -long orthforint(double r_maj, double center_lon, double center_lat, - double false_east, double false_north); -long orthfor( double lon, double lat, double *x, double *y); -long orthinvint(double r_maj, double center_lon, double center_lat, - double false_east, double false_north); -long orthinv(double x, double y, double *lon, double *lat); -double paksz(double ang, long *iflg); -long polyforint(double r_maj, double r_min, double center_lon, - double center_lat, double false_east, double false_north); -long polyfor(double lon, double lat, double *x, double *y); -long polyinvint(double r_maj, double r_min, double center_lon, - double center_lat, double false_east, double false_north); -long polyinv(double x, double y, double *lon, double *lat); -long psforint(double r_maj, double r_min, double c_lon, double c_lat, - double false_east, double false_north); -long psfor( double lon, double lat, double *x, double *y); -long psinvint(double r_maj, double r_min, double c_lon, double c_lat, - double false_east, double false_north); -long psinv( double x, double y, double *lon, double *lat); - -/* functions in report.c */ -void close_file(); -long init(long ipr, long jpr, char *efile, char *pfile); -void ptitle(char *A); -void radius(double A); -void radius2(double A, double B); -void cenlon( double A); -void cenlonmer(double A); -void cenlat(double A); -void origin(double A); -void stanparl(double A,double B); -void stparl1(double A); -void offsetp(double A, double B); -void genrpt(double A, char *S); -void genrpt_long(long A, char *S); -void pblank(); -void p_error(char *what, char *where); -/* End of the report.c functions */ - -long robforint(double r, double center_long, double false_east, - double false_north); -long robfor( double lon, double lat, double *x, double *y); -long robinvint(double r, double center_long, double false_east, - double false_north); -long robinv(double x, double y, double *lon, double *lat); -long sinforint(double r, double center_long, double false_east, - double false_north); -long sinfor(double lon, double lat, double *x, double *y); -long sininvint(double r, double center_long, double false_east, - double false_north); -long sininv(double x, double y, double *lon, double *lat); -long somforint(double r_major, double r_minor, long satnum, long path, - double alf_in, double lon, double false_east, double false_north, - double time, long start1, long flag); -long somfor(double lon, double lat, double *x, double *y); -/* WNE static double som_series(double *fb, double *fa2, double *fa4, double *fc1, - double *fc3,double *dlam); */ -long sominvint(double r_major, double r_minor, long satnum, long path, - double alf_in, double lon, double false_east, double false_north, - double time, long start1, long flag); -long sominv(double x, double y, double *lon, double *lat); -void sphdz(long isph, double *parm, double *r_major, double *r_minor, - double *radius); -long sterforint(double r_maj, double center_lon, double center_lat, - double false_east, double false_north); -long sterfor(double lon, double lat, double *x, double *y); -long sterinvint(double r_maj, double center_lon, double center_lat, - double false_east, double false_north); -long sterinv(double x, double y, double *lon, double *lat); -long stplnforint(long zone, long sphere, char *fn27, char *fn83); -long stplnfor(double lon, double lat, double *x, double *y); -long stplninvint(long zone, long sphere, char *fn27, char *fn83); -long stplninv(double x, double y, double *lon, double *lat); -long tmforint(double r_maj, double r_min, double scale_fact, - double center_lon, double center_lat, double false_east, - double false_north); -long tmfor(double lon, double lat, double *x, double *y); -long tminvint(double r_maj, double r_min, double scale_fact, - double center_lon, double center_lat, double false_east, - double false_north); -long tminv(double x, double y, double *lon, double *lat); -long untfz(long inunit, long outunit, double *factor); -long utmforint(double r_maj, double r_min, double scale_fact, long zone); -long utmfor(double lon, double lat, double *x, double *y); -long utminvint(double r_maj, double r_min, double scale_fact, long zone); -long vandgforint(double r, double center_long, double false_east, - double false_north); -long vandgfor( double lon, double lat, double *x, double *y); -long vandginvint(double r, double center_long, double false_east, - double false_north); -long vandginv(double x, double y, double *lon, double *lat); -long wivforint(double r, double center_long, double false_east, - double false_north); -long wivfor(double lon, double lat, double *x, double *y); -long wivinvint(double r, double center_long, double false_east, - double false_north); -long wivinv(double x, double y, double *lon, double *lat); -long wviiforint(double r, double center_long, double false_east, - double false_north); -long wviifor(double lon, double lat, double *x, double *y); -long wviiinvint( double r, double center_long, double false_east, - double false_north); -long wviiinv(double x, double y, double *lon, double *lat); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f2d730ec..d5d75e5f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -159,6 +159,17 @@ if (USE_JASPER OR USE_OPENJPEG) copy_test_data(ref_jpeg2simple.txt) endif() +if (MAKE_FTN_API) + shell_test(test_ftn_api) +endif() +if (BUILD_LIB) + shell_test(test_lib) +endif() +if (BUILD_SHARED_LIB) + shell_test(test_shared_lib) +endif() + + if (FTP_TEST_FILES) copy_test_data(ref_WW3_Regional_US_West_Coast_20220718_0000.grib2.inv) copy_test_data(ref_merge_fcst.aqm.t12z.max_8hr_o3.227.grib2.txt) diff --git a/tests/test_ftn_api.sh b/tests/test_ftn_api.sh new file mode 100755 index 00000000..fe8b079b --- /dev/null +++ b/tests/test_ftn_api.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# +# script to see if ftn_api compiled +# + +echo "see if ftn_api compiled" +set -xe + +if [ ! -f ../wgrib2/ftn_api/include/wgrib2api.mod ] ; then + echo "failed: did not find wgrib2api.mod" + exit 1 +fi + +echo "*** SUCCESS!" +exit 0 diff --git a/tests/test_lib.sh b/tests/test_lib.sh new file mode 100755 index 00000000..a7c46f1e --- /dev/null +++ b/tests/test_lib.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# +# script to see if shared lib was made +# + +echo "see if shared library made" +set -xe + +if [ ! -f ../wgrib2/libwgrib2.so -a ! -f ../wgrib2/libwgrib2.a ] ; then + echo "failed: did not find libwgrib2" + exit 1 +fi + +echo "*** SUCCESS!" +exit 0 diff --git a/tests/test_shared_lib.sh b/tests/test_shared_lib.sh new file mode 100755 index 00000000..fd96f986 --- /dev/null +++ b/tests/test_shared_lib.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# +# script to see if shared lib was made +# + +echo "see if shared library made" +set -xe + +if [ ! -f ../wgrib2/libwgrib2.so ] ; then + echo "failed: did not find libwgrib2.so" + exit 1 +fi + +echo "*** SUCCESS!" +exit 0 diff --git a/wgrib2/CMakeLists.txt b/wgrib2/CMakeLists.txt index 4a8033d3..315baa83 100644 --- a/wgrib2/CMakeLists.txt +++ b/wgrib2/CMakeLists.txt @@ -2,6 +2,19 @@ # subdirectory. # # Kyle Gerheiser, Edward Hartnett, Wesley Ebisuzaki +# +# if BUILD_SHARED_LIB +# ftn_api -> shared library, interface to fortran +# wgrib2_lib -> shared (includes gctpc) +# +# if !BUILD_SHARED_LIB +# ftn_api -> static library, interface to fortran +# wgrib2_lib -> static library includeing gctpc +# +# note: in wgrib2 v3.1.3 or earlier, all the libraries +# incuding aec, jasper, etc were included with the wgrib2 library +# in github version, it is different. + # sets lib_src set(lib_src AAIG.c AAIGlong.c addtime.c aec_pk.c Aerosol.c Alarm.c @@ -44,14 +57,16 @@ Type_reftime.c UDF.c Undefine.c units.c Unix_time.c Unmerge_fcst.c unpk_0.c unpk.c unpk_complex.c unpk_run_length.c update_sec3.c update_sec4.c v1_v2_if.c VerfTime.c Warn_old_g2lib.c Waves.c wgrib2_api.c wgrib2.c Wind_dir.c Wind_speed.c Wind_uv.c Write_sec.c -Wrt_grib.c wrtieee.c wxtext.c) +Wrt_grib.c wrtieee.c wxtext.c +) + +include_directories(gctpc/source/include) +add_subdirectory(gctpc) if(MAKE_FTN_API) add_subdirectory(ftn_api) endif() -add_subdirectory(gctpc) - # make this an object lib so we can re-use most of object files # The only files that differ are ${callable_src} which are compiled # with -DCALLABLE_WGRIB2 @@ -67,25 +82,27 @@ configure_file ( if(BUILD_LIB) - # with -DCALLABLE_WGRIB2 for the lib if(BUILD_SHARED_LIB) - add_library(wgrib2_lib SHARED ${lib_src} $ ${callable_src}) + add_library(wgrib2_lib SHARED ${lib_src} ) + set_property(TARGET wgrib2_lib PROPERTY POSITION_INDEPENDENT_CODE ON) else() - add_library(wgrib2_lib STATIC ${lib_src} $ ${callable_src}) + add_library(wgrib2_lib STATIC ${lib_src} $ ) +# add_library(wgrib2_lib STATIC ${lib_src} ) + set_property(TARGET wgrib2_lib PROPERTY POSITION_INDEPENDENT_CODE ON) endif() # library and executable have same name (wgrib2) but different target names set_target_properties(wgrib2_lib PROPERTIES OUTPUT_NAME wgrib2) - target_compile_definitions(wgrib2_lib PRIVATE CALLABLE_WGRIB2) + # target_compile_definitions(wgrib2_lib PRIVATE CALLABLE_WGRIB2) endif() -# without -DCALLABLE_WGRIB2 for the executable -add_executable(wgrib2_exe ${callable_src}) +add_executable(wgrib2_exe wgrib2_main.c) set_target_properties(wgrib2_exe PROPERTIES OUTPUT_NAME wgrib2) if(USE_NETCDF) target_link_libraries(obj_lib PUBLIC NetCDF::NetCDF_C) + target_link_libraries(wgrib2_exe PUBLIC NetCDF::NetCDF_C) endif() if(USE_JASPER) @@ -99,7 +116,7 @@ if(USE_PNG) endif() if(OpenMP_C_FOUND) - target_link_libraries(obj_lib PUBLIC OpenMP::OpenMP_C) +# target_link_libraries(obj_lib PUBLIC OpenMP::OpenMP_C) endif() if(USE_G2CLIB) @@ -107,6 +124,7 @@ endif() if(USE_IPOLATES) target_link_libraries(obj_lib PUBLIC ip::ip_d) + target_link_libraries(wgrib2_exe PUBLIC ip::ip_d) # Link to the Fortran runtime library for each compiler if using ip2. # The wgrib2 exectuable is created using the C compiler and @@ -119,9 +137,9 @@ if(USE_IPOLATES) endif() -target_link_libraries(obj_lib PUBLIC gctpc -lm) +## target_link_libraries(obj_lib PUBLIC gctpc -lm) -# Link to gctpc directly because oobject libraries do not link transitively +# Link to gctpc directly because object libraries do not link transitively target_link_libraries(wgrib2_exe PRIVATE gctpc) if(USE_AEC) @@ -134,10 +152,11 @@ if(USE_OPENJPEG) endif() target_link_libraries(wgrib2_exe PRIVATE obj_lib) +# target_link_libraries(wgrib2_exe PRIVATE wgrib2_lib) if(BUILD_LIB) set(headers wgrib2_api.h wgrib2.h ${CMAKE_BINARY_DIR}/wgrib2/wgrib2_meta.h) - target_link_libraries(wgrib2_lib PUBLIC gctpc) +## target_link_libraries(wgrib2_lib PUBLIC gctpc) set_target_properties(wgrib2_lib PROPERTIES PUBLIC_HEADER "${headers}") target_compile_definitions(wgrib2_lib PUBLIC ${definitions_list}) @@ -160,6 +179,3 @@ install( ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - - - diff --git a/wgrib2/fatal_error.c b/wgrib2/fatal_error.c index 7b94a430..2c6d949c 100644 --- a/wgrib2/fatal_error.c +++ b/wgrib2/fatal_error.c @@ -1,9 +1,9 @@ #include #include #include -#ifdef CALLABLE_WGRIB2 + #include -#endif + #include "wgrib2.h" /* @@ -17,9 +17,9 @@ * fprintf(ARGS) * do_fatal_error_processing */ -#ifdef CALLABLE_WGRIB2 + extern jmp_buf fatal_err; -#endif + void fatal_error(const char *fmt, ...) @@ -32,9 +32,9 @@ void fatal_error(const char *fmt, ...) va_end(arg); err_bin(1); err_string(1); -#ifdef CALLABLE_WGRIB2 + longjmp(fatal_err,1); -#endif + exit(8); return; } diff --git a/wgrib2/ftn_api/CMakeLists.txt b/wgrib2/ftn_api/CMakeLists.txt index 7a8a8c3a..81a77dbc 100644 --- a/wgrib2/ftn_api/CMakeLists.txt +++ b/wgrib2/ftn_api/CMakeLists.txt @@ -13,21 +13,26 @@ set(c_src fort_wgrib2.c ) -add_library(wgrib2_api ${fortran_src} ${c_src}) +if (BUILD_SHARED_LIB) + add_library(wgrib2_ftn_api SHARED ${fortran_src} ${c_src}) +else() + add_library(wgrib2_ftn_api STATIC ${fortran_src} ${c_src}) + set_property(TARGET wgrib2_ftn_api PROPERTY POSITION_INDEPENDENT_CODE ON) +endif() set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}") -set_target_properties(wgrib2_api PROPERTIES Fortran_MODULE_DIRECTORY ${module_dir}) +set_target_properties(wgrib2_ftn_api PROPERTIES Fortran_MODULE_DIRECTORY ${module_dir}) -target_include_directories(wgrib2_api +target_include_directories(wgrib2_ftn_api PUBLIC $ $) -target_link_libraries(wgrib2_api PUBLIC wgrib2_lib) +target_link_libraries(wgrib2_ftn_api PUBLIC wgrib2_lib) install(DIRECTORY ${module_dir} DESTINATION ${CMAKE_INSTALL_PREFIX}) install( - TARGETS wgrib2_api + TARGETS wgrib2_ftn_api EXPORT wgrib2_exports RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/wgrib2/gctpc/source/CMakeLists.txt b/wgrib2/gctpc/source/CMakeLists.txt index a077a587..8ec15725 100644 --- a/wgrib2/gctpc/source/CMakeLists.txt +++ b/wgrib2/gctpc/source/CMakeLists.txt @@ -1,3 +1,7 @@ +# note: this CMakelist.txt is for building the gctpc library +# wgrib2 now includes the library into the source compile +# so the wgrib2 library now include gctpc. This makes it +# easier for users who want to use the wgrib2 library. set(src alberfor.c @@ -76,10 +80,17 @@ set(src wviiinv.c ) +# if want shared library, had to make separate library +# otherwise include gctpc in libwgrib2.a + add_library(gctpc OBJECT ${src}) +if (BUILD_LIB) + set_property(TARGET gctpc PROPERTY POSITION_INDEPENDENT_CODE ON) +endif() target_include_directories(gctpc PUBLIC $ + # $ $) install( diff --git a/include/proj.h b/wgrib2/gctpc/source/proj.h similarity index 100% rename from include/proj.h rename to wgrib2/gctpc/source/proj.h diff --git a/wgrib2/wgrib2.c b/wgrib2/wgrib2.c index 806a5f26..b948ba35 100644 --- a/wgrib2/wgrib2.c +++ b/wgrib2/wgrib2.c @@ -1,4 +1,7 @@ -/* wgrib2 main module: public domain 2005 w. ebisuzaki +/* wgrib2: public domain 2005 w. ebisuzaki + * originally the main of the wgrib2 utility + * later became main or routine depending on CALLABLE_WGRIB2 + * finally wgrib2 utility became a wrapper that calls the wgrib2 routine * * CHECK code is now duplicated * if (decode) -- check before decoding @@ -17,10 +20,9 @@ #include #include -#ifdef CALLABLE_WGRIB2 + #include jmp_buf fatal_err; -#endif #include "grb2.h" #include "wgrib2.h" @@ -116,17 +118,9 @@ int version_if; /* 0-old stype 1-modern if */ * simple wgrib for GRIB2 files * */ -#ifndef CALLABLE_WGRIB2 - -int main(int argc, const char **argv) { - -#else int wgrib2(int argc, const char **argv) { -#endif - - //WNE FILE *in; struct seq_file in_file; unsigned char *msg, *sec[10]; /* sec[9] = last valid bitmap */ @@ -176,9 +170,9 @@ int wgrib2(int argc, const char **argv) { data = NULL; // ddata = NULL; -#ifdef CALLABLE_WGRIB2 + if (setjmp(fatal_err)) { - fprintf(stderr,"*** arg list to wgrib2:"); + fprintf(stderr,"*** arg list to wgrib2(..):"); for (i=0; i < argc; i++) { fprintf(stderr," %s", argv[i]); } @@ -186,9 +180,9 @@ int wgrib2(int argc, const char **argv) { if (ndata && data != NULL) free(data); ndata=0; if (in_file.file_type != NOT_OPEN) fclose_file(&in_file); - return 1; + return 8; } -#endif + /* no arguments .. help screen */ if (argc == 1) { @@ -565,7 +559,7 @@ int wgrib2(int argc, const char **argv) { if (GDS_max_size) free(old_gds); GDS_max_size = i + 100; /* add 100 just to avoid excessive memory allocations */ if ((old_gds = (unsigned char *) malloc(GDS_max_size) ) == NULL) { - fatal_error("memory allocation problem old_gds in wgrib2.main for %s",in_file.filename); + fatal_error("memory allocation problem old_gds in wgrib2(..) for %s",in_file.filename); } } #ifdef IS_OPENMP_4_0 @@ -692,7 +686,7 @@ int wgrib2(int argc, const char **argv) { data = (float *) malloc(sizeof(float) * (size_t) ndata); if (data == NULL) { ndata = 0; - fatal_error("main: memory allocation failed data",""); + fatal_error("wgrib2(..): memory allocation failed data",""); } } else { data = NULL; } diff --git a/wgrib2/wgrib2_api.c b/wgrib2/wgrib2_api.c index d99e866d..3f081f00 100644 --- a/wgrib2/wgrib2_api.c +++ b/wgrib2/wgrib2_api.c @@ -3,7 +3,6 @@ #include #include "wgrib2.h" -#ifdef CALLABLE_WGRIB2 /* sort of like the command line version of wgrib2 @@ -43,4 +42,3 @@ int wgrib2a(char *arg1, ...) { return i; } -#endif diff --git a/wgrib2/wgrib2_main.c b/wgrib2/wgrib2_main.c new file mode 100644 index 00000000..449ce054 --- /dev/null +++ b/wgrib2/wgrib2_main.c @@ -0,0 +1,27 @@ +/* wgrib2 main module: public domain 2024 w. ebisuzaki + * + * ancient: wgrib2.c was the main for the wgrib2 utility. There was no wgrib2 library, and + * no call to the wgrib2(..). + * + * old: A user wanted to call wgrib2 from a C program. He converted wgrib2.c to be either a main(..) + * or a routine wgrib2(..) depending on a flag (CALLABLE_WGRIB2). There were two builds, + * one for the utility and a second for the library. + * + * new: move to github + * Reimplement the old idea to make the wgrib2 utility a call to wgrib2(..). + * This involves removing all references to CALLABLE_WGRIB2 + * This was tested in a pre-github version but never implemented because it provided no reward + * With github, the build system is being rebuilt from Kyle's version. Rather than the two + * builds, make it a single build with the wgrib2 utility calling wgrib2(..) + + * + * 8/2024 the main for the wgrib2 utility is moved from wgrib2.c to wgrib2_main.c + */ + +#include +#include "wgrib2_api.h" + + +int main(int argc, const char **argv) { + return wgrib2(argc, argv); +} From fdccbd82a46711cddc37e5568959bc008a13b2e1 Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Fri, 18 Oct 2024 09:39:06 -0700 Subject: [PATCH 2/4] make_ftn_api should be off by default --- .github/workflows/developer.yml | 2 +- CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/developer.yml b/.github/workflows/developer.yml index fa9dd0d5..6755a5f8 100644 --- a/.github/workflows/developer.yml +++ b/.github/workflows/developer.yml @@ -110,7 +110,7 @@ jobs: export CFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0 -I/home/runner/g2c/include' export FCFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0' export FFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0' - cmake .. -DENABLE_DOCS=ON -DFTP_TEST_FILES=ON -DCMAKE_PREFIX_PATH="~/ip;~/jasper;~/g2c" -DTEST_FILE_DIR=/home/runner/data -DUSE_NETCDF4=ON -DUSE_AEC=ON -DUSE_IPOLATES=ON -DUSE_JASPER=ON + cmake .. -DENABLE_DOCS=ON -DFTP_TEST_FILES=ON -DCMAKE_PREFIX_PATH="~/ip;~/jasper;~/g2c" -DTEST_FILE_DIR=/home/runner/data -DUSE_NETCDF4=ON -DUSE_AEC=ON -DUSE_IPOLATES=ON -DUSE_JASPER=ON -DMAKE_FTN_API=ON make VERBOSE=1 ctest --verbose --output-on-failure --rerun-failed gcovr --root .. -v --html-details --exclude ../tests --exclude CMakeFiles --print-summary -o test-coverage.html &> /dev/null diff --git a/CMakeLists.txt b/CMakeLists.txt index 29b81e9e..3b87f976 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,7 @@ option(FTP_TEST_FILES "Fetch and test with files on FTP site." OFF) option(FTP_LARGE_TEST_FILES "Fetch and test with very large files on FTP site." OFF) option(FTP_EXTRA_TEST_FILES "Fetch even more large files from FTP and test them." OFF) # MAKE_FTN_API should only be on when building library -option(MAKE_FTN_API "add ftn api?" on) +option(MAKE_FTN_API "add ftn api?" off) option(DISABLE_STAT "disable posix feature" off) set(BUILD_COMMENTS "stock build") From aab547f6722fab5e822b715592da25d3b365951a Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Fri, 18 Oct 2024 10:07:21 -0700 Subject: [PATCH 3/4] fixing link math --- CMakeLists.txt | 4 ---- wgrib2/CMakeLists.txt | 2 +- wgrib2/gctpc/source/CMakeLists.txt | 1 - 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b87f976..5180776b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,10 +110,6 @@ if(USE_OPENJPEG AND USE_JASPER) message(FATAL_ERROR "USE_OPENJPEG OR USE_JASPER, not both") endif() - - - - message(STATUS "Checking if the user wants to use Jasper...") if(USE_JASPER) find_package(g2c 1.9.0 CONFIG REQUIRED) diff --git a/wgrib2/CMakeLists.txt b/wgrib2/CMakeLists.txt index 9342caa8..ec750d72 100644 --- a/wgrib2/CMakeLists.txt +++ b/wgrib2/CMakeLists.txt @@ -131,7 +131,7 @@ endif() ## target_link_libraries(obj_lib PUBLIC gctpc -lm) # Link to gctpc directly because object libraries do not link transitively -target_link_libraries(wgrib2_exe PRIVATE gctpc) +target_link_libraries(wgrib2_exe PRIVATE gctpc -lm) if(USE_AEC) target_link_libraries(wgrib2_exe PRIVATE ${LIBAEC_LIBRARIES}) diff --git a/wgrib2/gctpc/source/CMakeLists.txt b/wgrib2/gctpc/source/CMakeLists.txt index 8ec15725..8bf84a5b 100644 --- a/wgrib2/gctpc/source/CMakeLists.txt +++ b/wgrib2/gctpc/source/CMakeLists.txt @@ -90,7 +90,6 @@ endif() target_include_directories(gctpc PUBLIC $ - # $ $) install( From 08eae5019dd5ddf65899621fe77608d5b45eb6ec Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Fri, 18 Oct 2024 10:20:52 -0700 Subject: [PATCH 4/4] removed duplicate file --- wgrib2/gctpc/source/proj.h | 355 ------------------------------------- 1 file changed, 355 deletions(-) delete mode 100644 wgrib2/gctpc/source/proj.h diff --git a/wgrib2/gctpc/source/proj.h b/wgrib2/gctpc/source/proj.h deleted file mode 100644 index eb49170d..00000000 --- a/wgrib2/gctpc/source/proj.h +++ /dev/null @@ -1,355 +0,0 @@ -/* Projection codes - - - 0 = Geographic - 1 = Universal Transverse Mercator (UTM) - 2 = State Plane Coordinates - 3 = Albers Conical Equal Area - 4 = Lambert Conformal Conic - 5 = Mercator - 6 = Polar Stereographic - 7 = Polyconic - 8 = Equidistant Conic - 9 = Transverse Mercator - 10 = Stereographic - 11 = Lambert Azimuthal Equal Area - 12 = Azimuthal Equidistant - 13 = Gnomonic - 14 = Orthographic - 15 = General Vertical Near-Side Perspective - 16 = Sinusiodal - 17 = Equirectangular - 18 = Miller Cylindrical - 19 = Van der Grinten - 20 = (Hotine) Oblique Mercator - 21 = Robinson - 22 = Space Oblique Mercator (SOM) - 23 = Alaska Conformal - 24 = Interrupted Goode Homolosine - 25 = Mollweide - 26 = Interrupted Mollweide - 27 = Hammer - 28 = Wagner IV - 29 = Wagner VII - 30 = Oblated Equal Area - 99 = User defined -*/ - -/* Define projection codes */ -#define GEO 0 -#define UTM 1 -#define SPCS 2 -#define ALBERS 3 -#define LAMCC 4 -#define MERCAT 5 -#define PS 6 -#define POLYC 7 -#define EQUIDC 8 -#define TM 9 -#define STEREO 10 -#define LAMAZ 11 -#define AZMEQD 12 -#define GNOMON 13 -#define ORTHO 14 -#define GVNSP 15 -#define SNSOID 16 -#define EQRECT 17 -#define MILLER 18 -#define VGRINT 19 -#define HOM 20 -#define ROBIN 21 -#define SOM 22 -#define ALASKA 23 -#define GOOD 24 -#define MOLL 25 -#define IMOLL 26 -#define HAMMER 27 -#define WAGIV 28 -#define WAGVII 29 -#define OBEQA 30 -#define USDEF 99 - -/* Define unit code numbers to their names */ - -#define RADIAN 0 /* Radians */ -#define FEET 1 /* Feed */ -#define METER 2 /* Meters */ -#define SECOND 3 /* Seconds */ -#define DEGREE 4 /* Decimal degrees */ -#define INT_FEET 5 /* International Feet */ - -/* The STPLN_TABLE unit value is specifically used for State Plane -- if units - equals STPLN_TABLE and Datum is NAD83--actual units are retrieved from - a table according to the zone. If Datum is NAD27--actual units will be feet. - An error will occur with this unit if the projection is not State Plane. */ - -#define STPLN_TABLE 6 - -/* General code numbers */ - -#define IN_BREAK -2 /* Return status if the interupted projection - point lies in the break area */ -#define COEFCT 15 /* projection coefficient count */ -#define PROJCT 30 /* projection count */ -#define SPHDCT 31 /* spheroid count */ - -#define MAXPROJ 31 /* Maximum projection number */ -#define MAXUNIT 5 /* Maximum unit code number */ -#define GEO_TERM 0 /* Array index for print-to-term flag */ -#define GEO_FILE 1 /* Array index for print-to-file flag */ -#define GEO_TRUE 1 /* True value for geometric true/false flags */ -#define GEO_FALSE -1 /* False val for geometric true/false flags */ - -/* GCTP Function prototypes */ - -long alberforint(double r_maj, double r_min, double lat1, double lat2, - double lon0, double lat0, double false_east, double false_north); -long alberfor(double lon, double lat, double *x, double *y); -long alberinvint( double r_maj, double r_min, double lat1, double lat2, - double lon0, double lat0, double false_east, double false_north); -long alberinv( double x, double y, double *lon, double *lat); -long alconforint( double r_maj, double r_min, double false_east, - double false_north); -long alconfor(double lon, double lat, double *x, double *y); -long alconinvint( double r_maj, double r_min, double false_east, - double false_north); -long alconinv( double x, double y, double *lon, double *lat); -long azimforint( double r_maj, double center_lon, double center_lat, - double false_east, double false_north); -long azimfor( double lon, double lat, double *x, double *y); -long aziminvint( double r_maj, double center_lon, double center_lat, - double false_east, double false_north); -long aziminv( double x, double y, double *lon, double *lat); - -/* rename functions in gctpc */ - -void gctpc_sincos( double val, double *sin_val, double *cos_val); -#define sincos(a,b,c) gctpc_sincos(a,b,c) - -int gctpc_sign(double x); -#define sign(x) gctpc_sign(x) - - - -double asinz (double con); -double msfnz (double eccent, double sinphi, double cosphi); -double qsfnz (double eccent, double sinphi, double cosphi); -double phi1z (double eccent, double qs, long *flag); -double phi2z(double eccent, double ts, long *flag); -double phi3z(double ml, double e0, double e1, double e2, double e3, - long *flag); -double phi4z (double eccent, double e0, double e1, double e2, double e3, - double a, double b, double *c, double *phi); -double pakcz(double pak); -double pakr2dm(double pak); -double tsfnz(double eccent, double phi, double sinphi); -int sign(double x); -double adjust_lon(double x); -double e0fn(double x); -double e1fn(double x); -double e2fn(double x); -double e3fn(double x); -double e4fn(double x); -double mlfn(double e0,double e1,double e2,double e3,double phi); -long calc_utm_zone(double lon); -/* End of functions residing in cproj.h */ - -long eqconforint(double r_maj, double r_min, double lat1, double lat2, - double center_lon, double center_lat, double false_east, - double false_north, - long mode); -long eqconfor(double lon, double lat, double *x, double *y); -long eqconinvint(double r_maj, double r_min, double lat1, double lat2, - double center_lon, double center_lat, double false_east, - double false_north, long mode); -long eqconinv(double x, double y, double *lon, double *lat); -long equiforint(double r_maj, double center_lon, double lat1, - double false_east, double false_north); -long equifor(double lon, double lat, double *x, double *y); -long equiinvint(double r_maj, double center_lon, double lat1, - double false_east, double false_north); -long equiinv(double x, double y, double *lon, double *lat); -void for_init(long outsys, long outzone, double *outparm, long outspheroid, - char *fn27, char *fn83, long *iflg, long (*for_trans[])()); -void gctp(double *incoor, long *insys, long *inzone, double *inparm, - long *inunit, long *inspheroid, long *ipr, char *efile, long *jpr, - char *pfile, double *outcoor, long *outsys, long *outzone, - double *outparm, long *outunit, long *outspheroid, char fn27[], - char fn83[], long *iflg); -long gnomforint(double r, double center_long, double center_lat, - double false_east, double false_north); -long gnomfor(double lon, double lat, double *x, double *y); -long gnominvint(double r, double center_long, double center_lat, - double false_east, double false_north); -long gnominv(double x, double y, double *lon, double *lat); -long goodforint(double r); -long goodfor(double lon, double lat, double *x, double *y); -long goodinvint(double r); -long goodinv(double x, double y, double *lon, double *lat); -long gvnspforint(double r, double h, double center_long, double center_lat, - double false_east, double false_north); -long gvnspfor(double lon, double lat, double *x, double *y); -long gvnspinvint(double r, double h, double center_long, double center_lat, - double false_east, double false_north); -long gvnspinv(double x, double y, double *lon, double *lat); -long hamforint(double r, double center_long, double false_east, - double false_north); -long hamfor(double lon, double lat, double *x, double *y); -long haminvint(double r, double center_long, double false_east, - double false_north); -long haminv(double x, double y, double *lon, double *lat); -long imolwforint(double r); -long imolwfor(double lon, double lat, double *x, double *y); -long imolwinvint(double r); -long imolwinv(double x, double y, double *lon, double *lat); -void inv_init(long insys, long inzone, double *inparm, long inspheroid, - char *fn27, char *fn83, long *iflg, long (*inv_trans[])()); -long lamazforint(double r, double center_long, double center_lat, - double false_east, double false_north); -long lamazfor(double lon, double lat, double *x, double *y); -long lamazinvint(double r, double center_long, double center_lat, - double false_east, double false_north); -long lamazinv(double x, double y, double *lon, double *lat); -long lamccforint(double r_maj, double r_min, double lat1, double lat2, - double c_lon, double c_lat, double false_east, double false_north); -long lamccfor(double lon, double lat, double *x, double *y); -long lamccinvint(double r_maj, double r_min, double lat1, double lat2, - double c_lon, double c_lat, double false_east, double false_north); -long lamccinv(double x, double y, double *lon, double *lat); -long merforint(double r_maj, double r_min, double center_lon, double center_lat, - double false_east, double false_north); -long merfor(double lon, double lat, double *x, double *y); -long merinvint(double r_maj, double r_min, double center_lon, double center_lat, - double false_east, double false_north); -long merinv(double x, double y, double *lon, double *lat); -long millforint(double r, double center_long, double false_east, - double false_north); -long millfor(double lon, double lat, double *x, double *y); -long millinvint(double r, double center_long, double false_east, - double false_north); -long millinv(double x, double y, double *lon, double *lat); -long molwforint(double r, double center_long, double false_east, - double false_north); -long molwfor(double lon, double lat, double *x, double *y); -long molwinvint(double r, double center_long, double false_east, - double false_north); -long molwinv(double x, double y, double *lon, double *lat); -long obleqforint(double r, double center_long, double center_lat, - double shape_m, double shape_n, double angle, double false_east, - double false_north); -long obleqfor(double lon, double lat, double *x, double *y); -long obleqinvint(double r, double center_long, double center_lat, - double shape_m, double shape_n, double angle, double false_east, - double false_north); -long omerforint(double r_maj, double r_min, double scale_fact, - double azimuth, double lon_orig, double lat_orig, double false_east, - double false_north, double lon1, double lat1, double lon2, double lat2, - long mode); -long omerfor(double lon, double lat, double *x, double *y); -long omerinvint(double r_maj, double r_min, double scale_fact, double azimuth, - double lon_orig, double lat_orig, double false_east, double false_north, - double lon1, double lat1, double lon2, double lat2, long mode); -long omerinv(double x, double y, double *lon, double *lat); -long orthforint(double r_maj, double center_lon, double center_lat, - double false_east, double false_north); -long orthfor( double lon, double lat, double *x, double *y); -long orthinvint(double r_maj, double center_lon, double center_lat, - double false_east, double false_north); -long orthinv(double x, double y, double *lon, double *lat); -double paksz(double ang, long *iflg); -long polyforint(double r_maj, double r_min, double center_lon, - double center_lat, double false_east, double false_north); -long polyfor(double lon, double lat, double *x, double *y); -long polyinvint(double r_maj, double r_min, double center_lon, - double center_lat, double false_east, double false_north); -long polyinv(double x, double y, double *lon, double *lat); -long psforint(double r_maj, double r_min, double c_lon, double c_lat, - double false_east, double false_north); -long psfor( double lon, double lat, double *x, double *y); -long psinvint(double r_maj, double r_min, double c_lon, double c_lat, - double false_east, double false_north); -long psinv( double x, double y, double *lon, double *lat); - -/* functions in report.c */ -void close_file(); -long init(long ipr, long jpr, char *efile, char *pfile); -void ptitle(char *A); -void radius(double A); -void radius2(double A, double B); -void cenlon( double A); -void cenlonmer(double A); -void cenlat(double A); -void origin(double A); -void stanparl(double A,double B); -void stparl1(double A); -void offsetp(double A, double B); -void genrpt(double A, char *S); -void genrpt_long(long A, char *S); -void pblank(); -void p_error(char *what, char *where); -/* End of the report.c functions */ - -long robforint(double r, double center_long, double false_east, - double false_north); -long robfor( double lon, double lat, double *x, double *y); -long robinvint(double r, double center_long, double false_east, - double false_north); -long robinv(double x, double y, double *lon, double *lat); -long sinforint(double r, double center_long, double false_east, - double false_north); -long sinfor(double lon, double lat, double *x, double *y); -long sininvint(double r, double center_long, double false_east, - double false_north); -long sininv(double x, double y, double *lon, double *lat); -long somforint(double r_major, double r_minor, long satnum, long path, - double alf_in, double lon, double false_east, double false_north, - double time, long start1, long flag); -long somfor(double lon, double lat, double *x, double *y); -/* WNE static double som_series(double *fb, double *fa2, double *fa4, double *fc1, - double *fc3,double *dlam); */ -long sominvint(double r_major, double r_minor, long satnum, long path, - double alf_in, double lon, double false_east, double false_north, - double time, long start1, long flag); -long sominv(double x, double y, double *lon, double *lat); -void sphdz(long isph, double *parm, double *r_major, double *r_minor, - double *radius); -long sterforint(double r_maj, double center_lon, double center_lat, - double false_east, double false_north); -long sterfor(double lon, double lat, double *x, double *y); -long sterinvint(double r_maj, double center_lon, double center_lat, - double false_east, double false_north); -long sterinv(double x, double y, double *lon, double *lat); -long stplnforint(long zone, long sphere, char *fn27, char *fn83); -long stplnfor(double lon, double lat, double *x, double *y); -long stplninvint(long zone, long sphere, char *fn27, char *fn83); -long stplninv(double x, double y, double *lon, double *lat); -long tmforint(double r_maj, double r_min, double scale_fact, - double center_lon, double center_lat, double false_east, - double false_north); -long tmfor(double lon, double lat, double *x, double *y); -long tminvint(double r_maj, double r_min, double scale_fact, - double center_lon, double center_lat, double false_east, - double false_north); -long tminv(double x, double y, double *lon, double *lat); -long untfz(long inunit, long outunit, double *factor); -long utmforint(double r_maj, double r_min, double scale_fact, long zone); -long utmfor(double lon, double lat, double *x, double *y); -long utminvint(double r_maj, double r_min, double scale_fact, long zone); -long vandgforint(double r, double center_long, double false_east, - double false_north); -long vandgfor( double lon, double lat, double *x, double *y); -long vandginvint(double r, double center_long, double false_east, - double false_north); -long vandginv(double x, double y, double *lon, double *lat); -long wivforint(double r, double center_long, double false_east, - double false_north); -long wivfor(double lon, double lat, double *x, double *y); -long wivinvint(double r, double center_long, double false_east, - double false_north); -long wivinv(double x, double y, double *lon, double *lat); -long wviiforint(double r, double center_long, double false_east, - double false_north); -long wviifor(double lon, double lat, double *x, double *y); -long wviiinvint( double r, double center_long, double false_east, - double false_north); -long wviiinv(double x, double y, double *lon, double *lat);