func.h

00001 #include "mm5io.h"
00002 #include <stdio.h>
00003 #include <hdf5.h>
00004 
00005 #include <F5/F5F.h>
00006 #include <F5/F5R.h>
00007 #include <F5/F5coordinates.h>
00008 /* -------------------------------------------------------------------------- */
00009 /*  DEFINITIONS                                                               */
00010 /* -------------------------------------------------------------------------- */
00011 #define BIG       0
00012 #define LITTLE    1
00013 #define BIG_HEADER 0
00014 #define SUB_HEADER 1
00015 
00016 /* -------------------------------------------------------------------------- */
00017 /* FUNCTION    : check_endian                                                 */
00018 /* DESCRIPTION : Checks if this machine is little/big endian                  */
00019 /* IN DATA     : none                                                         */
00020 /* OUT DATA    : none                                                         */
00021 /* RETURN      : BIG or LITTLE                                                */
00022 /* -------------------------------------------------------------------------- */
00023 int check_endian();
00024 
00025 /* -------------------------------------------------------------------------- */
00026 /* FUNCTION    : swab4                                                        */
00027 /* DESCRIPTION : swaps 4 bytes values from/to little/big endian               */
00028 /* IN DATA     : none                                                         */
00029 /* OUT DATA    : swapped value                                                */
00030 /* RETURN      : none                                                         */
00031 /* -------------------------------------------------------------------------- */
00032 void swab4(void *value);
00033 
00034 
00035 /* -------------------------------------------------------------------------- */
00036 /* FUNCTION    : fort_read                                                 */
00037 /* DESCRIPTION : Reads a record from a fortran unformatted file (big endian)  */
00038 /* IN DATA     : pointer to result, size of data type, number of data type,
00039                                               pointer to file, machine order  */
00040 /* OUT DATA    : record                                                       */
00041 /* RETURN      : record size on completion, -1 on error                       */
00042 /* -------------------------------------------------------------------------- */
00043 int fort_read(void* record, size_t size, size_t num, FILE* flnm, int machorder);
00044 
00045 /* -------------------------------------------------------------------------- */
00046 /* FUNCTION    : fort_print                                              */
00047 /* DESCRIPTION : print a fortran format string                           */
00048 /* IN DATA     : pointer to the string, length of string              */
00049 /* OUT DATA    : print to std                                                    */
00050 /* RETURN      : char printed on completion, -1 on error                       */
00051 /* -------------------------------------------------------------------------- */
00052 int fort_print(char* ptr, int num);
00053 
00054 /* -------------------------------------------------------------------------- */
00055 /* FUNCTION    : process_header                                              */
00056 /* DESCRIPTION : change fortran format to c format                           */
00057 /* IN DATA     : pointer to the header, header type              */
00058 /* OUT DATA    : pointer to processed header                                 */
00059 /* RETURN      : nothing                                                     */
00060 /* -------------------------------------------------------------------------- */
00061 
00062 void process_header(void* header, int type);
00063 
00064 
00065 /* -------------------------------------------------------------------------- */
00066 /* FUNCTION    : fort_read_field                                       */
00067 /* DESCRIPTION : read field data into memory                           */
00068 /* IN DATA     : pointer to file, No of dims, array of No of data in every dim   */
00069 /* OUT DATA    :                                                                                      */
00070 /* RETURN      : pointer to filed start                                          */
00071 /* -------------------------------------------------------------------------- */
00072 
00073 int fort_read_field(FILE* input, float** field, int* ndim, int* end_index,int machorder);
00074 
00075 
00076 /* -------------------------------------------------------------------------- */
00077 /* FUNCTION    : time_char_double                                       */
00078 /* DESCRIPTION : converte char[24] time to double format                           */
00079 /* IN DATA     : the pointer to the start of char[24]     */
00080 /* OUT DATA    :                                                                      */
00081 /* RETURN      : float date                                          */
00082 /* -------------------------------------------------------------------------- */
00083 
00084 double time_char_double( char* ctime);
00085 
00086 /* -------------------------------------------------------------------------- */
00087 /* FUNCTION    : write_vdata                                       */
00088 /* DESCRIPTION : convert scalar data to vector data and write to .f5 file        */
00089 /* IN DATA     : fpath, subh, vdata     */
00090 /* OUT DATA    :                                                                      */
00091 /* RETURN      :                                        */
00092 /* -------------------------------------------------------------------------- */
00093 
00094 void write_vdata(F5Path* fpath, t_mm5v3_sub_header subh, F5_vec3f_t* vdata, float* field);
00095 
00096