[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #NZK-292950]: problem in compiling FAN languagem and utilities



Greetings Patrick,

> Hi, I'm trying to compile FAN 2.0.3 on Ubuntu, but make is terminating
> with the following error "In file included from d2nc.c:10: nc.h:129:
> error: MAX_NC_OPEN undeclared here (not in a function)".
> 
> I read that MAX_NC_OPEN was just defined in old versions of netcdf.h.

It's been quite some time since netCDf used MAX_NC_OPEN. Currently, netCDF 
allows the OS to take care of this limit, rather than hard coding one.

> 
> I need to downgrade my netcdf version? Is it enough to just define
> MAX_NC_OPEN in the files that use it? What is the canonical solution
> for this problem?

You could add the following to d2nc.c after #include <netcdf.h>

#define MAX_NC_OPEN `number`

where `number` used to be 32. Here is some C code that will ask your OS for its 
maximum value:

sysconf_test.c

/////////////
#include <stdio.h> 
#include <unistd.h> 

int main (){

    int max_files;

    max_files = sysconf(_SC_OPEN_MAX); 

    printf("\nsysconf _SC_OPEN_MAX says you can use the following:\n\n");
    printf("#define MAX_NC_OPEN %i\n\n", max_files); 

return 0;
} 
/////////////

gcc sysconf_test.c -o sysconf_test

The output on my system is:
------------
./sysconf_test 

sysconf _SC_OPEN_MAX says you can use the following:

#define MAX_NC_OPEN 1024

------------

At the suggestion of Russ Rew, I've CCd Harvey Davies to this email, as he is 
the developer of FAN, and this info may help for any future plans to develop 
FAN.

Cheers!

Sean Arms

> 
> Thanks,
> 
> Patrick Maia
> +55 83 8740-8192
> 
> 


Ticket Details
===================
Ticket ID: NZK-292950
Department: Support netCDF
Priority: Normal
Status: Open