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

20050713: wavelet decompression ADDE server code (cont.)

>From:  "Valentijn Venus" <address@hidden>
>Organization:  ITC
>Keywords: 200507011338.j61DcBjo014148 McIDAS MSG wavlet development

Hi Valentijn,

re: is GINI server code in standard McIDAS distribution
>Thanks for the info.

No worries.

>Which lines exactly handle the decompression of the data (in

There are several sections that need to deal with compressed 

file: giniutil.c


GetGiniHeader( FILELIST *cur, unsigned char *header )

GetGiniLine( FILELIST *cur, READPARM *read, int band, unsigned char *buf,
             char *err )

>I guess this c code for uncompressing the GINI image
>data was already in c?


>Any suggestions/advice before we start modding?

McIDAS has a lot of examples of C calling Fortran and Fortran calling
C.  The biggest things to remember are:

- most Fortran compilers add a trailing underscore ('_') after entry point
  names.   This means that compiled entry points will have a trailing
  underscore and calls to routines in Fortran will have a trailing

- C strings are null terminated; Fortran strings are not

- Fortran uses call by reference, not by value

>I believe t here are >10.000 lines just to do the wavelett tranform, so
>we'll have to call the c routines form the msgtaget2.for...

Fortran calling C is not hard.  One simple example of C code that
can called directly by C can be found in ~mcidas/mcidas2004/src/swbyt4_.c:

swbyt4_(void *buf, Fint *n)
        /* determine byte order from first principles */
                char            bytes[sizeof(Mcint4)];
                Mcint4          word;
        }               q;

        q.word = 1;
        if (q.bytes[3] == 1)

        /* swap bytes */
        fbyte4_(buf, n);


- source code is C
- the type of the routine is 'void'; it is called by Fortran as a
- entry point has a trailing underscore (swbyt4_)
- the arguments are picked up by reference (i.e., by address)

Here is some Fortran code that calls this C code:


Fortran          C
ICOL             void *
1                Fint *

Fint (along with other types used in McIDAS) is defined in 'mcidas.h':

/* Fint is the C equivalent of Fortran INTEGER */
#ifndef _Fint
#define _Fint
    typedef int Fint;


* Tom Yoksas                                             UCAR Unidata Program *
* (303) 497-8642 (last resort)                                  P.O. Box 3000 *
* address@hidden                                   Boulder, CO 80307 *
* Unidata WWW Service                             http://www.unidata.ucar.edu/*

NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.