Skip to content

Commit

Permalink
updates from current NCL code base
Browse files Browse the repository at this point in the history
  • Loading branch information
david-ian-brown authored and Ryan Cabell committed Dec 22, 2018
1 parent 2ca56c5 commit 620f5df
Show file tree
Hide file tree
Showing 118 changed files with 3,133 additions and 2,003 deletions.
13 changes: 6 additions & 7 deletions libsrc/AdvancedFileSupport.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/

#include <string.h>
#include <ctype.h>
#include "AdvancedFileSupport.h"

NclQuark *GetGrpVarNames(void *therec, int *num_vars)
Expand Down Expand Up @@ -646,15 +647,13 @@ void _Ncl_add_udt(NclFileUDTRecord **rootudtrec,
udtnode->max_fields = nfields;
udtnode->n_fields = nfields;

udtnode->mem_name = (NclQuark *)NclCalloc(nfields, sizeof(NclQuark));
assert(udtnode->mem_name);
udtnode->mem_type = (NclBasicDataTypes *)NclCalloc(nfields, sizeof(NclBasicDataTypes));
assert(udtnode->mem_type);

udtnode->fields = (NclFileUDTField *) NclCalloc(nfields, sizeof(NclFileUDTField));
assert(udtnode->fields);

for(n = 0; n < nfields; n++)
{
udtnode->mem_name[n] = mem_name[n];
udtnode->mem_type[n] = mem_type[n];
udtnode->fields[n].field_name = mem_name[n];
udtnode->fields[n].field_type = mem_type[n];
}

udtrec->n_udts ++;
Expand Down
2 changes: 1 addition & 1 deletion libsrc/DataSupport.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* $Id: DataSupport.c 16525 2016-06-07 21:47:33Z dbrown $
* $Id$
*/
/************************************************************************
* *
Expand Down
28 changes: 21 additions & 7 deletions libsrc/FileSupport.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

/*
* $Id: FileSupport.c 16530 2016-06-14 22:36:10Z dbrown $
* $Id$
*/
/************************************************************************
* *
Expand Down Expand Up @@ -3784,6 +3784,7 @@ NclQuark _NclFindFileExt(NclQuark path, NclQuark *fname_q, NhlBoolean *is_http,
return file_ext_q;
}
else if(*end_of_name == NULL) {
*fname_q = NrmStringToQuark(last_slash);
return file_ext_q; /* this is still -1 */
} else {
*len_path = *end_of_name - the_path;
Expand Down Expand Up @@ -4116,16 +4117,17 @@ NclFile _NclOpenFile(NclObj inst, NclObjClass theclass, NclObjTypes obj_type,
NclFile file_out = NULL;

NclQuark file_ext_q = -1;
NclQuark fname_q;
NclQuark fname_q = NrmNULLQUARK;
NhlBoolean is_http;
char *end_of_name = NULL;
int len_path;

struct stat file_stat;
struct stat file_stat;
short use_advanced_file_structure = 0;
NclFileClassPart *fcp = &(nclFileClassRec.file_class);
NrmQuark afs = NrmStringToQuark("advanced");
NrmQuark sfs = _NclGetLower(*(NrmQuark *)(fcp->options[Ncl_ADVANCED_FILE_STRUCTURE].value->multidval.val));
NclQuark the_real_path = path;

file_ext_q = _NclFindFileExt(path, &fname_q, &is_http, &end_of_name, &len_path, rw_status, &use_advanced_file_structure);

Expand Down Expand Up @@ -4158,14 +4160,25 @@ NclFile _NclOpenFile(NclObj inst, NclObjClass theclass, NclObjTypes obj_type,
}
else if (rw_status > -1)
{
NclQuark the_real_path = NrmStringToQuark(_NGResolvePath(NrmQuarkToString(path)));
the_real_path = NrmStringToQuark(_NGResolvePath(NrmQuarkToString(path)));

/* Handle cases where _NGResolvePath(path) returns NULL */
if (NrmQuarkToString(the_real_path) == NULL)
{
NhlPError(NhlWARNING,NhlEUNKNOWN,
"_NclOpenFile: cannot resolve path <%s>; check for undefined environment variables",
NrmQuarkToString(path));
return file_out;
}

NclQuark old_file_ext_q = file_ext_q;
int stat_ret;

file_ext_q = -1;

if ((0 == stat(NrmQuarkToString(the_real_path), &file_stat)) &&
(S_ISREG(file_stat.st_mode) || S_ISLNK (file_stat.st_mode)))
/*file_stat.st_size &&*/
(S_ISREG(file_stat.st_mode) || S_ISLNK (file_stat.st_mode)))
file_ext_q = _NclVerifyFile(the_real_path, old_file_ext_q, &use_advanced_file_structure);
else
{
Expand All @@ -4189,6 +4202,7 @@ NclFile _NclOpenFile(NclObj inst, NclObjClass theclass, NclObjTypes obj_type,
NrmQuarkToString(the_real_path),strerror(errno));
return file_out;
}
the_real_path = NrmStringToQuark(tmp_path);

}

Expand All @@ -4205,12 +4219,12 @@ NclFile _NclOpenFile(NclObj inst, NclObjClass theclass, NclObjTypes obj_type,
if (use_advanced_file_structure)
{
file_out = _NclAdvancedFileCreate(inst, theclass, obj_type, obj_type_mask, status,
path, rw_status, file_ext_q, fname_q, is_http, end_of_name, len_path);
the_real_path, rw_status, file_ext_q, fname_q, is_http, end_of_name, len_path);
}
else
{
file_out = _NclFileCreate(inst, theclass, obj_type, obj_type_mask, status,
path, rw_status, file_ext_q, fname_q, is_http, end_of_name, len_path);
the_real_path, rw_status, file_ext_q, fname_q, is_http, end_of_name, len_path);
}

return file_out;
Expand Down
2 changes: 1 addition & 1 deletion libsrc/FileSupport.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* $Id: FileSupport.h 16525 2016-06-07 21:47:33Z dbrown $
* $Id$
*/
/************************************************************************
* *
Expand Down
35 changes: 9 additions & 26 deletions libsrc/GetGrids.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,6 @@
#include <math.h>
#include <unistd.h>

extern void NGCALLF(mdppos,MDPPOS)(double *, double *, double *, double *);
extern void NGCALLF(mdproj,MDPROJ)(char *, double *, double *, double *);
/*
extern void NGCALLF(mdpset,MDPSET)(char *, double *, double *, double *, double *);
*/
extern void NGCALLF(mdpint,MDPINT)();
extern void NGCALLF(gdswiz,GDSWIZ)(int *, int *, int *, float *,
float *, float *, float *, float *,
int *, int *, float *, float *);
extern void NGCALLF(mdptrn,MDPTRN)(double *, double *, double *, double *);
extern void NGCALLF(mdptri,MDPTRI)(double *, double *, double *, double *);
extern void NGCALLF(qu2reg3,QU2REG3)(float *, int *, int *, int *, int *,
float *, int *, int *, int *, int *,
int *, float *, float *, float *);
extern void NGCALLF(gaqdnio,GAQDNIO)(int *, double *, double *, double *, int *, int *);
extern void NGCALLF(maptrn,MAPTRN)(float *, float*, float *, float *);
extern void NGCALLF(maptri,MAPTRI)(float *, float*, float *, float *);

static void GenAtts(
#if NhlNeedProto
GribParamList* thevarrec,
Expand All @@ -53,7 +35,7 @@ int *rotatts
#endif
);

static void InitMapTrans
void _NclInitMapTrans
#if NhlNeedProto
(
char *proj,
Expand All @@ -75,13 +57,14 @@ static void InitMapTrans
int len;
NGstring str;

NGCALLF(mapbd,MAPBD)();
NGCALLF(mdppos,MDPPOS)(&fl,&fr,&fb,&ft);
len = NGSTRLEN(proj);
str = NGCstrToFstr(proj,len);
NGCALLF(mdproj,MDPROJ)(str,&plat,&plon,&prot);
NGCALLF(mdproj,MDPROJ)(str,&plat,&plon,&prot,len);
len = NGSTRLEN("MA");
str = NGCstrToFstr("MA",len);
NGCALLF(mdpset,MDPSET)(str,&rl,&rl,&rl,&rl);
NGCALLF(mdpset,MDPSET)(str,rl,rl,rl,rl,len);
NGCALLF(mdpint,MDPINT)();
}

Expand Down Expand Up @@ -542,7 +525,7 @@ int ny;
dlat0 = lat0;
dlat1 = lat1;

InitMapTrans("ME",0.0,(dlon1 - dlon0)/2.0,0.0);
_NclInitMapTrans("ME",0.0,(dlon1 - dlon0)/2.0,0.0);

*lat = (float*)NclMalloc(sizeof(float)*ny);
*lon = (float*)NclMalloc(sizeof(float)*nx);
Expand Down Expand Up @@ -874,7 +857,7 @@ void GenLambert
int i,j;
double an;

InitMapTrans("LC",lat0,lon0,lat1);
_NclInitMapTrans("LC",lat0,lon0,lat1);

/* this has already been done now */
*lat = (float*)NclMalloc(sizeof(float)*nx*ny);
Expand Down Expand Up @@ -8228,7 +8211,7 @@ int* nrotatts;
lat1 = la2 / 1000.0;
latin1 = latin/1000.0;

InitMapTrans("ME",0,idir * (lon1 - lon0)/2.0,0.0);
_NclInitMapTrans("ME",0,idir * (lon1 - lon0)/2.0,0.0);

tmplon = (lon1-lon0) / 2.0;
tmplat = (lat1 - lat0) / 2.0;
Expand Down Expand Up @@ -9077,7 +9060,7 @@ int* nrotatts;
}

if(north) {
InitMapTrans("ST",90.0,lov,0.0);
_NclInitMapTrans("ST",90.0,lov,0.0);
/*
* Northern case
*/
Expand Down Expand Up @@ -9108,7 +9091,7 @@ int* nrotatts;
}
}
} else {
InitMapTrans("ST",-90.0,lov,0.0);
_NclInitMapTrans("ST",-90.0,lov,0.0);
/*
* Southern case
*/
Expand Down
Loading

0 comments on commit 620f5df

Please sign in to comment.