Commit 6ce70813 authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Automatically populate default model entries.

parent 21a7ca90
......@@ -29,7 +29,6 @@ model_t;
static int MODEL_Debug = 0; /* If set to 1, debugging */
static int * modelInitializedNsp;
static void modelInit(void);
......@@ -77,7 +76,6 @@ model_t *modelNewEntry ( void )
int modelDef(int instID, int modelgribID, const char *name);
static
void modelDefaultEntries ( void )
{
int instID, i;
......@@ -112,37 +110,16 @@ void modelDefaultEntries ( void )
reshSetStatus(resH[i], &modelOps, RESH_PRE_ASSIGNED);
}
static
void modelFinalize ( void )
{
free ( modelInitializedNsp );
}
static
void modelInit(void)
{
static int modelInitialized = 0;
int nsp, nspc;
char *env;
nspc = namespaceGetNumber ();
if ( !modelInitialized )
{
modelInitialized = 1;
modelInitializedNsp = (int*) xcalloc ( 1, nspc * sizeof ( int ));
atexit ( modelFinalize );
env = getenv("MODEL_DEBUG");
if ( env ) MODEL_Debug = atoi(env);
}
nsp = namespaceGetActive ();
if ( modelInitializedNsp[nsp] ) return;
modelInitializedNsp[nsp] = 1;
if (modelInitialized) return;
modelDefaultEntries ();
modelInitialized = 1;
char *env = getenv("MODEL_DEBUG");
if ( env ) MODEL_Debug = atoi(env);
}
int modelSize ( void )
......
......@@ -5,6 +5,8 @@ int
modelUnpack(void *buf, int size, int *position,
int, void *context);
void modelDefaultEntries(void);
#endif
/*
* Local Variables:
......
......@@ -18,6 +18,7 @@
#include "file.h"
#include "resource_unpack.h"
#include "institution.h"
#include "model.h"
enum { MIN_LIST_SIZE = 128 };
......@@ -98,6 +99,7 @@ listInitResources(int nsp)
int oldNsp = namespaceGetActive();
namespaceSetActive(nsp);
instituteDefaultEntries();
modelDefaultEntries();
namespaceSetActive(oldNsp);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment