Skip to content

Commit

Permalink
Sir geom (#16)
Browse files Browse the repository at this point in the history
* MOdifications to remove sir_geom as a separate library

Moved ease2_map_info into the utils.c code as it is used in both
make and setup.  Moved the remaining sir_geom routines into setup
as they are only used there.

* Deleted the sir_geom directories

* Removed sirlib/c directory from Uber Makefile

* Defined RTD and DTR using M_PI from math.h

* Cleaning up compilation warnings

* Change "math.h" to <math.h>
  • Loading branch information
mollyhardman authored Aug 8, 2024
1 parent 160b809 commit 8027d48
Show file tree
Hide file tree
Showing 14 changed files with 512 additions and 1,199 deletions.
18 changes: 9 additions & 9 deletions regression_scripts/run_regression.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
regressiontype=$1
condaenv=$2

if [ "$1" == "-h" ] || [ "$#" -ne 2 ] ; then
if [[ $1 == -h ]] || [[ $# != 2 ]] ; then
echo ""
echo "Usage: `basename $0` [-h] REGRESSIONTYPE CONDAENV"
echo " Runs quick (fast, does less) or "
Expand All @@ -25,16 +25,16 @@ if [ "$1" == "-h" ] || [ "$#" -ne 2 ] ; then
echo " REGRESSIONTYPE: quick or daily"
echo " CONDENV: name of conda env with python2 and nose"
echo ""
exit 1
return 1
fi

if [ "$regressiontype" != "quick" ] && [ "$regressiontype" != "daily" ] ; then
if [[ $regressiontype != quick ]] && [[ $regressiontype != daily ]] ; then
echo "`basename $0`: invalid regressiontype, should be quick or daily"
exit 1
return 1
fi

maketarget=${regressiontype}
if [ "$regressiontype" == "daily" ] ; then
if [[ $regressiontype == daily ]] ; then
maketarget="ease"
fi

Expand All @@ -53,26 +53,26 @@ pwd
make csu_${maketarget}
if [ $? -ne 0 ]; then
echo "`basename $0`: csu_${maketarget} make failed"
exit -1
return -1
fi
echo "`basename $0`: running setup"
cd ${PMESDR_TOP_DIR}/src/prod/meas_meta_setup
pwd
make csu_${maketarget}
if [ $? -ne 0 ]; then
echo "`basename $0`: csu_$maketarget setup failed"
exit -1
return -1
fi
echo "`basename $0`: running sir"
cd ${PMESDR_TOP_DIR}/src/prod/meas_meta_sir
pwd
make csu_${maketarget}
if [ $? -ne 0 ]; then
echo "`basename $0`: csu_${maketarget} SIR failed"
exit -1
return -1
fi
make csu_${maketarget}_validate
if [ $? -ne 0 ]; then
echo "`basename $0`: csu_$maketarget SIR validate failed"
exit -1
return -1
fi
2 changes: 1 addition & 1 deletion src/prod/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ CONDAENV = ${PMESDR_CONDAENV}
#------------------------------------------------------------------------

SUBDIRS = calcalcs/src utils/src cetb_file/src gsx/src \
../sirlib/c meas_meta_make meas_meta_setup meas_meta_sir
meas_meta_make meas_meta_setup meas_meta_sir

all install clean:
for i in $(SUBDIRS); do \
Expand Down
16 changes: 9 additions & 7 deletions src/prod/meas_meta_make/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#
TOPDIR = $(PMESDR_TOP_DIR)
BINDIR = $(TOPDIR)/bin
LIBDIR = $(TOPDIR)/lib
INCDIR = $(TOPDIR)/include

TESTINPUT = $(PMESDR_TOP_DIR)/src/test_inputs
Expand Down Expand Up @@ -47,27 +48,28 @@ SYSLIBS = -lm
#
# end configuration section
#------------------------------------------------------------------------
MEAS_INCDIR = ../../sirlib/c/include
MEAS_LIBDIR = ../../sirlib/c
LIBS = -L$(MEAS_LIBDIR) -lcsir $(SYSLIBS)
CFLAGS = -I$(INCDIR) -I$(MEAS_INCDIR) -m64 $(CONFIG_CFLAGS) -Wall -Wno-unused-variable
LIBS = -L$(LIBDIR) -lutils $(SYSLIBS)
CFLAGS = -I$(INCDIR) -m64 $(CONFIG_CFLAGS) -Wall -Wno-unused-variable
ifeq ($(LOCALE),ALPINEicc)
$(info Build location: $(LOCALE))
CFLAGS = -D'ALPINEicc=1' -I$(INCDIR) -I$(MEAS_INCDIR) $(CONFIG_CFLAGS) -O3 -ipo -xHost -Wall -Wremarks -wd981 -no-prec-div -wd2415
CFLAGS = -D'ALPINEicc=1' -I$(INCDIR) $(CONFIG_CFLAGS) -O3 -ipo -xHost -Wall -Wremarks -wd981 -no-prec-div -wd2415
endif

DEPEND_LIBS = $(MEAS_LIBDIR)/libcsir.a
DEPEND_LIBS = $(LIBDIR)/libutils.a

SRCS = meas_meta_make.c
OBJS = meas_meta_make.o
HDRS = $(MEAS_INCDIR)/sir_geom.h $(INCDIR)/cetb.h
HDRS = $(INCDIR)/cetb.h $(INCDIR)/utils.h
BIN = meas_meta_make

all : $(BIN)

$(BIN) : $(OBJS) $(HDRS) $(DEPEND_LIBS)
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS)

meas_meta_make.o : $(SRCS) $(HDRS)
$(CC) -c $(CFLAGS) -o $@ $(SRCS)

install :
$(MKDIR) $(BINDIR)
$(INSTALL) $(BIN) $(BINDIR)
Expand Down
51 changes: 13 additions & 38 deletions src/prod/meas_meta_make/meas_meta_make.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef JANUSicc
#include <mathimf.h>
#else
#include <math.h>
#endif
#include <time.h>

#include <cetb.h>
#include <sir_geom.h>
#include "cetb.h"
#include "utils.h"

#define prog_version 1.2 /* program version */
#define prog_name "meas_meta_make"
Expand All @@ -32,21 +28,14 @@
#define TRUE 1
#define FALSE 0

/****************************************************************************/
/* default location of the SIR standard region definition */

char rname[] = "regiondef1.dat"; /* file defining region codes */

/********************************************************************/

/* function prototypes */

static int get_region_parms( FILE *mout, int *argn, char *argv[], int F_num,
float response_threshold_dB, int resolution_ind );

static int get_file_names(FILE *mout, int *argn, char *argv[]);

static void get_region_data(int regnum, int resolution_ind, int *iproj, int *dateline, float *latl,
static void get_region_data(int regnum, int resolution_ind, int *iproj, float *latl,
float *lonl, float *lath, float *lonh, char *regname);

/****************************************************************************/
Expand Down Expand Up @@ -254,15 +243,14 @@ static int get_file_names(FILE *mout, int *argn, char *argv[])
*
* output:
* int *iproj - short version of region id (i.e. 8 rather than 308 etc)
* int dateline - this is always zero for our projections - might not be needed
* float *latl, *lonl - latitude and longitude of lower left corner
* of lower left corner pixel
* float *lath, *lonh - latitude and longitude of upper right corner
* of upper right corner pixel
* char *regname - EASE2_N etc.
*/
static void get_region_data(int regnum, int resolution_ind, int *iproj,
int *dateline, float *latl, float *lonl,
float *latl, float *lonl,
float *lath, float *lonh, char *regname)
{
cetb_region_id cetb_region;
Expand All @@ -271,14 +259,13 @@ static void get_region_data(int regnum, int resolution_ind, int *iproj,
projection_offset = regnum - CETB_PROJECTION_BASE_NUMBER;
cetb_region = (cetb_region_id)( projection_offset +
(CETB_NUMBER_BASE_RESOLUTIONS * resolution_ind) );
dateline = 0;

strncpy( regname, cetb_region_id_name[ resolution_ind ][ projection_offset ],
CETB_MAX_LEN_REGION_ID_NAME );
*latl = cetb_latitude_extent[ resolution_ind ][ projection_offset ][0];
*lath = cetb_latitude_extent[ resolution_ind ][ projection_offset ][1];
*lonl = cetb_longitude_extent[ resolution_ind ][ projection_offset ][0];
*lonh = cetb_longitude_extent[ resolution_ind ][ projection_offset ][1];
*latl = (float)cetb_latitude_extent[ resolution_ind ][ projection_offset ][0];
*lath = (float)cetb_latitude_extent[ resolution_ind ][ projection_offset ][1];
*lonl = (float)cetb_longitude_extent[ resolution_ind ][ projection_offset ][0];
*lonh = (float)cetb_longitude_extent[ resolution_ind ][ projection_offset ][1];

switch ( cetb_region ) {
case CETB_EASE2_N:
Expand Down Expand Up @@ -338,11 +325,10 @@ static int get_region_parms( FILE *mout, int *argn, char *argv[], int F_num,
char rfile[250];
int pfile;
FILE *pid;
int nregions, poleflag, dateline, iproj, regnum, iregion, ircnt;
int nregions, poleflag, iproj, regnum, iregion, ircnt;
float latl, lonl, lath, lonh;
int projt, nsx, nsy, xdim, ydim, nease;
float ascale, bscale, xdeg, ydeg, a0, b0, aorglon, aorglat;
float maplxlon, maprxlon;
int iasc, ibeam, ipolar;
int non_size;
int nsect, nsx2, nsy2;
Expand Down Expand Up @@ -426,7 +412,6 @@ static int get_region_parms( FILE *mout, int *argn, char *argv[], int F_num,

ircnt=0; /* count total regions */
for (iregion=0; iregion<nregions; iregion++) {
dateline=FALSE;

/* region ID number */

Expand All @@ -436,11 +421,11 @@ static int get_region_parms( FILE *mout, int *argn, char *argv[], int F_num,
/* define region, using auto definition if possible */
strncpy( regname, "Custom", 10);
if (regnum > 0) { /* get region definition from contents of cetb.h */
get_region_data( regnum, resolution_ind, &iproj, &dateline, &latl, &lonl,
get_region_data( regnum, resolution_ind, &iproj, &latl, &lonl,
&lath, &lonh, regname );
if (((regnum >= 0) && (regnum < 100)) || (regnum >= 120)) poleflag=0; /* non-polar area */
fprintf( stderr, "%s: Region name: '%s' Def Proj %d Dateline %d\n",
__FUNCTION__, regname, iproj, dateline );
fprintf( stderr, "%s: Region name: '%s' Def Proj %d \n",
__FUNCTION__, regname, iproj );
} else {
fprintf( stderr, "%s: Region is not defined and out of bounds\n", __FUNCTION__ );
exit(-1);
Expand All @@ -452,15 +437,6 @@ static int get_region_parms( FILE *mout, int *argn, char *argv[], int F_num,
fprintf( stderr, "%s: Longitude range: %f %f\n", __FUNCTION__, lonl, lonh );
fprintf( stderr, "%s: Region polar code (0=arbitrary, 1=N pol, 2=S pole: %d\n",
__FUNCTION__, poleflag );
if (dateline) {
fprintf( stderr, "%s: Region crosses dateline\n", __FUNCTION__ );
maplxlon=min(lonh,lonl);
maprxlon=max(lonh,lonl);
lonl=maplxlon;
lonh=maprxlon;
fprintf( stderr, "%s: Corrected longitude range: %f %f\n",
__FUNCTION__, lonl, lonh );
}

/* write region ID number and bound box info to meta file */
fprintf(mout," Begin_region_description\n");
Expand All @@ -469,7 +445,6 @@ static int get_region_parms( FILE *mout, int *argn, char *argv[], int F_num,
fprintf(mout," Latitude_high=%16.9f\n", lath);
fprintf(mout," Longitude_low=%16.9f\n", lonl);
fprintf(mout," Longitude_high=%16.9f\n", lonh);
fprintf(mout," Dateline_crossing=%c\n", TF[dateline]);
fprintf(mout," Polar_flag=%c\n", TF[poleflag]);
fprintf(mout," Region_name=%s\n", regname);

Expand Down Expand Up @@ -499,7 +474,7 @@ static int get_region_parms( FILE *mout, int *argn, char *argv[], int F_num,
ind=resolution_ind; /* standard base resolution */
fprintf( stderr, "%s: EASE2 parameters: proj=%d nease=%d ind=%d\n",
__FUNCTION__, projt, nease, ind);
ease2_map_info(projt, nease, ind, &map_equatorial_radius_m,
utils_ease2_map_info(projt, nease, ind, &map_equatorial_radius_m,
&map_eccentricity, &e2,
&map_reference_latitude, &map_reference_longitude,
&map_second_reference_latitude, &sin_phi1, &cos_phi1, &kz,
Expand Down
12 changes: 5 additions & 7 deletions src/prod/meas_meta_setup/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,29 +81,27 @@ endif
#
# end configuration section
#------------------------------------------------------------------------
MEAS_INCDIR = ../../sirlib/c/include
MEAS_LIBDIR =
LIBS = -L$(LIBDIR) -L$(NETCDF4_LIBDIR) -L$(HDF5_LIBDIR) -L$(UDUNITS_LIBDIR) \
-lgsx -lutils -lcalcalcs -ludunits2 -lcsir \
-lgsx -lutils -lcalcalcs -ludunits2 \
-lnetcdf -l$(HDFLIB1) -l$(HDFLIB2) -lz $(SYSLIBS)
CFLAGS = -I$(INCDIR) -I$(NETCDF4_INCDIR) -I$(HDF5_INCDIR) -I$(UDUNITS_INCDIR) \
-I$(MEAS_INCDIR) $(CONFIG_CFLAGS) -Wall -Wno-unused-variable
$(CONFIG_CFLAGS) -Wall -Wno-unused-variable
ifeq ($(LOCALE),ALPINEicc)
$(info Build location: $(LOCALE))
CFLAGS = -D'ALPINEicc=1' -I$(INCDIR) -I$(NETCDF4_INCDIR) -I$(HDF5_INCDIR) \
-I$(UDUNITS_INCDIR) -I$(MEAS_INCDIR) -ipo -xHost -no-prec-div \
-I$(UDUNITS_INCDIR) -ipo -xHost -no-prec-div \
-Wall -Wremarks -wd981 -wd2415 -inline-level=0
endif


DEPEND_LIBS = $(LIBDIR)/libutils.a \
$(LIBDIR)/libcalcalcs.a \
$(UDUNITS_LIBDIR)/libudunits2.a \
$(LIBDIR)/libgsx.a $(LIBDIR)/libcsir.a
$(LIBDIR)/libgsx.a

SRCS = meas_meta_setup.c
OBJS = meas_meta_setup.o
HDRS = $(INCDIR)/gsx.h $(INCDIR)/cetb.h $(MEAS_INCDIR)/sir_geom.h \
HDRS = $(INCDIR)/gsx.h $(INCDIR)/cetb.h $(INCDIR)/utils.h \
$(INCDIR)/utCalendar2_cal.h
BIN = meas_meta_setup

Expand Down
Loading

0 comments on commit 8027d48

Please sign in to comment.