Skip to content

Commit

Permalink
trying ip build
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardhartnett committed Mar 27, 2024
1 parent 5d51504 commit 330f18c
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 241 deletions.
25 changes: 14 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# This is the main CMake build file for the wgrib2 project.
#
# Kyle Gerheiser, Edward Hartnett, Wesley Ebisuzaki

cmake_minimum_required(VERSION 3.12)
project(wgrib2 VERSION 3.1.4 LANGUAGES Fortran C)


option(USE_NETCDF3 "Use NetCDF-3?" off)
option(USE_NETCDF4 "Use NetCDF-4?" off)
option(USE_HDF5 "Use HDF5?" off)
Expand Down Expand Up @@ -42,6 +45,7 @@ endif()

include(GNUInstallDirs)

message(STATUS "Setting compiler flags...")
if(CMAKE_C_COMPILER_ID MATCHES "^(Intel)$")
set(CMAKE_C_FLAGS "-g -traceback ${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS_DEBUG "-O0")
Expand All @@ -59,6 +63,7 @@ elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$")
endif()


message(STATUS "Checking if user wants to use NCEPLIBS-g2c...")
if(USE_G2CLIB)
if(USE_PNG)
message(FATAL_ERROR "If USE_G2CLIB is on, USE_PNG must be off")
Expand All @@ -74,6 +79,7 @@ if(USE_NETCDF3 AND USE_NETCDF4)
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 EQUAL 1)
find_package(ip CONFIG REQUIRED)
find_package(sp CONFIG REQUIRED)
Expand All @@ -86,11 +92,13 @@ if(NOT USE_IPOLATES EQUAL 0)
endif()
list(APPEND definitions_list -DUSE_IPOLATES=${USE_IPOLATES})

message(STATUS "Checking if the user want to use NetCDF...")
if(USE_NETCDF4)
find_package(NetCDF MODULE REQUIRED COMPONENTS C)
list(APPEND definitions_list -DUSE_NETCDF4 -DUSE_HDF5 -DHDF5="hdf5")
endif()

message(STATUS "Checking if the user wants to use Jasper...")
if(USE_JASPER)
list(APPEND definitions_list -DUSE_JASPER)
find_package(Jasper REQUIRED)
Expand All @@ -99,6 +107,7 @@ if(USE_JASPER)
endif()
endif()

message(STATUS "Checking if the user want to use OpenMP...")
if(USE_OPENMP)
find_package(OpenMP)
if(OpenMP_CXX_FOUND)
Expand All @@ -109,13 +118,14 @@ if(USE_OPENMP)
# endif()
endif()

message(STATUS "Checking of the user wants to use PNG...")
if(USE_PNG)
find_package(ZLIB REQUIRED)
find_package(PNG REQUIRED)
endif()


# write config.h
message(STATUS "Writing config.h...")
FILE(WRITE "wgrib2/config.h" "/* config.h generated by cmake */\n")
FILE(APPEND "wgrib2/config.h" "#ifndef _CONFIG_H\n")
FILE(APPEND "wgrib2/config.h" "#define _CONFIG_H\n")
Expand All @@ -140,21 +150,14 @@ FILE(APPEND "wgrib2/config.h" "#define CC \"${CMAKE_C_COMPILER} ${CMAKE_C_COMPIL
FILE(APPEND "wgrib2/config.h" "#define FORTRAN \"${CMAKE_Fortran_COMPILER} ${CMAKE_Fortran_COMPILER_ID}\"\n")
FILE(APPEND "wgrib2/config.h" "#define CPPFLAGS \"${CMAKE_C_FLAGS}\"\n")
FILE(APPEND "wgrib2/config.h" "#define FFLAGS \"${CMAKE_Fortran_FLAGS}\"\n")



FILE(APPEND "wgrib2/config.h" "#endif\n")





message(STATUS "Adding wgrib2, aux_probs subdirectories...")
add_subdirectory(wgrib2)
add_subdirectory(aux_progs)


if(BUILD_LIB)

message(STATUS "Adding wgrib2 library build...")
### Package config
include(CMakePackageConfigHelpers)
set(CONFIG_INSTALL_DESTINATION lib/cmake/${PROJECT_NAME})
Expand Down
276 changes: 46 additions & 230 deletions wgrib2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,235 +1,51 @@
# This is the CMake build file for the wgrib2 project, wgrib2
# subdirectory.
#
# Kyle Gerheiser, Edward Hartnett, Wesley Ebisuzaki

# sets lib_src
set(lib_src
AAIG.c
AAIGlong.c
addtime.c
aec_pk.c
Aerosol.c
Alarm.c
Alias.c
Ave_test.c
Ave_var.c
Bbox.c
bitstream.c
Box_ave.c
Check_pdt_size.c
Checksum.c
Cluster.c
cname.c
codetable_4_230.c
CodeTable.c
Code_Values.c
Code_Values_JMA.c
complex_pk.c
Config.c
copy.c
crc32.c
Cress_lola.c
Csv.c
Csv_long.c
cubed_sphere2ll.c
CubeFace2global.c
Cyclic.c
Data.c
decenc_openjpeg.c
dec_png_clone.c
Dump.c
Earth.c
Else.c
enc_jpeg2000_clone.c
End.c
Endif.c
Ensemble.c
Ens_processing.c
Ens_qc.c
EOF.c
Export_lonlat.c
ExtName.c
fatal_error.c
Fcst_ave.c
ffopen.c
Fi.c
File.c
Fix_CFSv2_fcst.c
Fix_ncep_2.c
Fix_ncep_3.c
Fix_ncep_4.c
Fix_ncep.c
Fix_undef.c
FlagTable.c
flt2ieee.c
flt2ieee_nan.c
Flush.c
fnlist.c
For.c
Ftime1.c
Ftime2.c
Ftime.c
Ftn_api.c
gaussian2ij.c
Gctpc.c
gctpc_ll2xy.c
GDT.c
geo.c
Geolocation.c
get_unixtime.c
Grads.c
Grib.c
Grib_out_irr2.c
Grib_out_irr.c
gribtab.c
Gribtable_used.c
Grid_def.c
Grid_id.c
grid_ident.c
Gridout.c
Help.c
Hybrid.c
ieee2flt.c
ieee2flt_nan.c
ieee_pk.c
If_delayed_error.c
If_rec.c
Import.c
Import_grib.c
Import_grib_fs.c
Import_lonlat.c
Import_netcdf.c
init.c
int8.c
intpower.c
Inv.c
Inv_no.c
Irr_grids.c
itoshort_a.c
JMA.c
jpeg_pk.c
Last.c
lat2ij.c
Latlon.c
Level.c
Limit.c
Lola.c
Lvl.c
Macro.c
manage_inv_out.c
Match.c
Match_fs.c
Match_inv.c
Mem_buffer.c
Merge.c
Misc.c
missing.c
mk_gdt.c
mk_kgds.c
Model_version_date.c
Mod_grib.c
Mysql.c
Mysql_dump.c
Mysql_speed.c
Names.c
ncep_grids.c
NCEP_norm.c
NCEP_uv.c
Ncpu.c
Ndate.c
Ndates.c
Netcdf.c
Netcdf_sup.c
New_grid.c
new_grid_lambertc.c
New_grid_order.c
openmp_util.c
parse_loop.c
parse_msg.c
pdt_len.c
Precision.c
Prob.c
Proj4.c
proj4_initialize.c
proj4_transform.c
PyInv.c
Range.c
rdieee_file.c
rd_inventory.c
rd_seq_grib.c
read_latlon.c
Reduced_gaussian_grid.c
Reset_delayed_error.c
rotll.c
RPN.c
save_string.c
Scaling_0001.c
Scan.c
Sec0.c
Sec1.c
Sec3.c
sec3_grids.c
Sec4.c
Sec5.c
Sec6.c
Sec_len.c
Set_byte.c
Set_date.c
Set_ensm_derived_fcst.c
Set_ens_num.c
Set_ftime1.c
Set_ftime2.c
Set_ftime_mode.c
Set_gds.c
Set_metadata.c
Set_pdt.c
Set_percentile.c
Set_prob.c
Set_sec_size.c
Set_ts_dates.c
setup_user_gribtable.c
Set_val.c
simple_pk.c
Small_grib.c
space_view2ij.c
space_view.c
SpatialProcessing.c
Spectral_bands.c
stagger.c
Status.c
string2time_unit.c
Submsg_uv.c
subtime.c
Summary.c
swap_buffer.c
test_sec.c
Tigge.c
Time_processing.c
Timer.c
Tosubmsg.c
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
)
set(lib_src AAIG.c AAIGlong.c addtime.c aec_pk.c Aerosol.c Alarm.c
Alias.c Ave_test.c Ave_var.c Bbox.c bitstream.c Box_ave.c
Check_pdt_size.c Checksum.c Cluster.c cname.c codetable_4_230.c
CodeTable.c Code_Values.c Code_Values_JMA.c complex_pk.c Config.c
copy.c crc32.c Cress_lola.c Csv.c Csv_long.c cubed_sphere2ll.c
CubeFace2global.c Cyclic.c Data.c decenc_openjpeg.c dec_png_clone.c
Dump.c Earth.c Else.c enc_jpeg2000_clone.c End.c Endif.c Ensemble.c
Ens_processing.c Ens_qc.c EOF.c Export_lonlat.c ExtName.c
fatal_error.c Fcst_ave.c ffopen.c Fi.c File.c Fix_CFSv2_fcst.c
Fix_ncep_2.c Fix_ncep_3.c Fix_ncep_4.c Fix_ncep.c Fix_undef.c
FlagTable.c flt2ieee.c flt2ieee_nan.c Flush.c fnlist.c For.c Ftime1.c
Ftime2.c Ftime.c Ftn_api.c gaussian2ij.c Gctpc.c gctpc_ll2xy.c GDT.c
geo.c Geolocation.c get_unixtime.c Grads.c Grib.c Grib_out_irr2.c
Grib_out_irr.c gribtab.c Gribtable_used.c Grid_def.c Grid_id.c
grid_ident.c Gridout.c Help.c Hybrid.c ieee2flt.c ieee2flt_nan.c
ieee_pk.c If_delayed_error.c If_rec.c Import.c Import_grib.c
Import_grib_fs.c Import_lonlat.c Import_netcdf.c init.c int8.c
intpower.c Inv.c Inv_no.c Irr_grids.c itoshort_a.c JMA.c jpeg_pk.c
Last.c lat2ij.c Latlon.c Level.c Limit.c Lola.c Lvl.c Macro.c
manage_inv_out.c Match.c Match_fs.c Match_inv.c Mem_buffer.c Merge.c
Misc.c missing.c mk_gdt.c mk_kgds.c Model_version_date.c Mod_grib.c
Mysql.c Mysql_dump.c Mysql_speed.c Names.c ncep_grids.c NCEP_norm.c
NCEP_uv.c Ncpu.c Ndate.c Ndates.c Netcdf.c Netcdf_sup.c New_grid.c
new_grid_lambertc.c New_grid_order.c openmp_util.c parse_loop.c
parse_msg.c pdt_len.c Precision.c Prob.c Proj4.c proj4_initialize.c
proj4_transform.c PyInv.c Range.c rdieee_file.c rd_inventory.c
rd_seq_grib.c read_latlon.c Reduced_gaussian_grid.c
Reset_delayed_error.c rotll.c RPN.c save_string.c Scaling_0001.c
Scan.c Sec0.c Sec1.c Sec3.c sec3_grids.c Sec4.c Sec5.c Sec6.c
Sec_len.c Set_byte.c Set_date.c Set_ensm_derived_fcst.c Set_ens_num.c
Set_ftime1.c Set_ftime2.c Set_ftime_mode.c Set_gds.c Set_metadata.c
Set_pdt.c Set_percentile.c Set_prob.c Set_sec_size.c Set_ts_dates.c
setup_user_gribtable.c Set_val.c simple_pk.c Small_grib.c
space_view2ij.c space_view.c SpatialProcessing.c Spectral_bands.c
stagger.c Status.c string2time_unit.c Submsg_uv.c subtime.c Summary.c
swap_buffer.c test_sec.c Tigge.c Time_processing.c Timer.c Tosubmsg.c
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)

if(MAKE_FTN_API)
list(APPEND lib_src
ftn_api/fort_wgrib2.c ftn_api/wgrib2api.f90 ftn_api/wgrib2lowapi.f90 )
Expand Down

0 comments on commit 330f18c

Please sign in to comment.