Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • mesonh/mesonh-code
  • quentin.rodier/mesonh-code-fork
  • benoit.vie/mesonh-code
  • joris.pianezze/mesonh-code
  • 8qq4g5s7/mesonh-code
  • jean.baptiste.filippi/meso-nh-fire-code
  • fdl68d9p/mesonh-code-sophia
7 results
Show changes
Showing
with 9958 additions and 0 deletions
This diff is collapsed.
/* Vis5D version 5.1 */
/*
Vis5D system for visualizing five dimensional gridded data sets
Copyright (C) 1990 - 1996 Bill Hibbard, Brian Paul, Dave Santek,
and Andre Battaiola.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef V5D_H
#define V5D_H
/*
* A numeric version number which we can test for in utility programs which
* use the v5d functions. For example, we can do tests like this:
* #if V5D_VERSION > 42
* do something
* #else
* do something else
* #endif
*
* If V5D_VERSION is not defined, then its value is considered to be zero.
*/
#define V5D_VERSION 42
/*
* Define our own 1 and 2-byte data types. We use these names to avoid
* collisions with types defined by the OS include files.
*/
typedef unsigned char V5Dubyte; /* Must be 1 byte, except for cray */
typedef unsigned short V5Dushort; /* Must be 2 byte, except for cray */
#define MISSING 1.0e35
#define IS_MISSING(X) ( (X) >= 1.0e30 )
/* Limits on 5-D grid size: (must match those in v5df.h!!!) */
#define MAXVARS 100
#define MAXTIMES 400
#define MAXROWS 800
#define MAXCOLUMNS 800
#define MAXLEVELS 100
#ifdef VPP
#define FLOAT double
#else
#define FLOAT float
#endif
/************************************************************************/
/*** ***/
/*** Functions for writing v5d files. See README file for details. ***/
/*** These are the functions user's will want for writing file ***/
/*** converters, etc. ***/
/*** ***/
/************************************************************************/
extern int v5dCreateSimple( const char *name,
int numtimes, int numvars,
int nr, int nc, int nl,
const char varname[MAXVARS][10],
const int timestamp[],
const int datestamp[],
float northlat, float latinc,
float westlon, float loninc,
float bottomhgt, float hgtinc );
extern int v5dCreate( const char *name,
int numtimes, int numvars,
int nr, int nc, const int nl[],
const char varname[MAXVARS][10],
const int timestamp[],
const int datestamp[],
int compressmode,
int projection,
const FLOAT proj_args[],
int vertical,
const FLOAT vert_args[] );
extern int v5dWrite( int time, int var, const FLOAT data[] );
extern int v5dClose( void );
extern int v5dSetLowLev( int lowlev[] );
extern int v5dSetUnits( int var, const char *units );
/************************************************************************/
/*** ***/
/*** Definition of v5d struct and function prototypes. ***/
/*** These functions are used by vis5d and advanced v5d utilities. ***/
/*** ***/
/************************************************************************/
#define MAXPROJARGS 100
#define MAXVERTARGS (MAXLEVELS+1)
/*
* This struct describes the structure of a .v5d file.
*/
typedef struct {
/* PUBLIC (user can freely read, sometimes write, these fields) */
int NumTimes; /* Number of time steps */
int NumVars; /* Number of variables */
int Nr; /* Number of rows */
int Nc; /* Number of columns */
int Nl[MAXVARS]; /* Number of levels per variable */
int LowLev[MAXVARS]; /* Lowest level per variable */
char VarName[MAXVARS][10]; /* 9-character variable names */
char Units[MAXVARS][20]; /* 19-character units for variables */
int TimeStamp[MAXTIMES]; /* Time in HHMMSS format */
int DateStamp[MAXTIMES]; /* Date in YYDDD format */
float MinVal[MAXVARS]; /* Minimum variable data values */
float MaxVal[MAXVARS]; /* Maximum variable data values */
/* This info is used for external function computation */
short McFile[MAXTIMES][MAXVARS];/* McIDAS file number in 1..9999 */
short McGrid[MAXTIMES][MAXVARS];/* McIDAS grid number in 1..? */
int VerticalSystem; /* Which vertical coordinate system */
float VertArgs[MAXVERTARGS]; /* Vert. Coord. Sys. arguments... */
/*
IF VerticalSystem==0 THEN
-- Linear scale, equally-spaced levels in generic units
VertArgs[0] = Height of bottom-most grid level in generic units
VertArgs[1] = Increment between levels in generic units
ELSE IF VerticalSystem==1 THEN
-- Linear scale, equally-spaced levels in km
VertArgs[0] = Height of bottom grid level in km
VertArgs[1] = Increment between levels in km
ELSE IF VerticalSystem==2 THEN
-- Linear scale, Unequally spaced levels in km
VertArgs[0] = Height of grid level 0 (bottom) in km
... ...
VertArgs[n] = Height of grid level n in km
ELSE IF VerticalSystem==3 THEN
-- Linear scale, Unequally spaced levels in mb
VertArgs[0] = Pressure of grid level 0 (bottom) in mb
... ...
VertArgs[n] = Pressure of grid level n in mb
ENDIF
*/
int Projection; /* Which map projection */
float ProjArgs[MAXPROJARGS]; /* Map projection arguments... */
/*
IF Projection==0 THEN
-- Rectilinear grid, generic units
ProjArgs[0] = North bound, Y coordinate of grid row 0
ProjArgs[1] = West bound, X coordiante of grid column 0
ProjArgs[2] = Increment between rows
ProjArgs[3] = Increment between colums
NOTES: X coordinates increase to the right, Y increase upward.
NOTES: Coordinate system is right-handed.
ELSE IF Projection==1 THEN
-- Cylindrical equidistant (Old VIS-5D)
-- Rectilinear grid in lat/lon
ProjArgs[0] = Latitude of grid row 0, north bound, in degrees
ProjArgs[1] = Longitude of grid column 0, west bound, in deg.
ProjArgs[2] = Increment between rows in degrees
ProjArgs[3] = Increment between rows in degrees
NOTES: Coordinates (degrees) increase to the left and upward.
ELSE IF Projection==2 THEN
-- Lambert conformal
ProjArgs[0] = Standared Latitude 1 of conic projection
ProjArgs[1] = Standared Latitude 2 of conic projection
ProjArgs[2] = Row of North/South pole
ProjArgs[3] = Column of North/South pole
ProjArgs[4] = Longitude which is parallel to columns
ProjArgs[5] = Increment between grid columns in km
ELSE IF Projection==3 THEN
-- Polar Stereographic
ProjArgs[0] = Latitude of center of projection
ProjArgs[1] = Longitude of center of projection
ProjArgs[2] = Grid row of center of projection
ProjArgs[3] = Grid column of center of projection
ProjArgs[4] = Increment between grid columns at center in km
ELSE IF Projection==4 THEN
-- Rotated
ProjArgs[0] = Latitude on rotated globe of grid row 0
ProjArgs[1] = Longitude on rotated globe of grid column 0
ProjArgs[2] = Degrees of latitude on rotated globe between
grid rows
ProjArgs[3] = Degrees of longitude on rotated globe between
grid columns
ProjArgs[4] = Earth latitude of (0, 0) on rotated globe
ProjArgs[5] = Earth longitude of (0, 0) on rotated globe
ProjArgs[6] = Clockwise rotation of rotated globe in degrees
ENDIF
*/
int CompressMode; /* 1, 2 or 4 = # bytes per grid point */
char FileVersion[10]; /* 9-character version number */
/* PRIVATE (not to be touched by user code) */
unsigned int FileFormat; /* COMP5D file version or 0 if .v5d */
int FileDesc; /* Unix file descriptor */
char Mode; /* 'r' = read, 'w' = write */
int CurPos; /* current position of file pointer */
int FirstGridPos; /* position of first grid in file */
int GridSize[MAXVARS]; /* size of each grid */
int SumGridSizes; /* sum of GridSize[0..NumVars-1] */
} v5dstruct;
extern float pressure_to_height( float pressure);
extern float height_to_pressure( float height );
extern int v5dYYDDDtoDays( int yyddd );
extern int v5dHHMMSStoSeconds( int hhmmss );
extern int v5dDaysToYYDDD( int days );
extern int v5dSecondsToHHMMSS( int seconds );
extern void v5dPrintStruct( const v5dstruct *v );
extern v5dstruct *v5dNewStruct( void );
extern void v5dFreeStruct( v5dstruct* v );
extern void v5dInitStruct( v5dstruct *v );
extern int v5dVerifyStruct( const v5dstruct *v );
extern void v5dCompressGrid( int nr, int nc, int nl, int compressmode,
const float data[], void *compdata,
float ga[], float gb[],
float *minval, float *maxval );
extern void v5dDecompressGrid( int nr, int nc, int nl, int compressmode,
void *compdata,
float ga[], float gb[],
float data[] );
extern int v5dSizeofGrid( const v5dstruct *v, int time, int var );
extern v5dstruct *v5dOpenFile( const char *filename, v5dstruct *v );
extern int v5dCreateFile( const char *filename, v5dstruct *v );
extern v5dstruct *v5dUpdateFile( const char *filename, v5dstruct *v );
extern int v5dCloseFile( v5dstruct *v );
extern int v5dReadCompressedGrid( v5dstruct *v,
int time, int var,
float *ga, float *gb,
void *compdata );
extern int v5dReadGrid( v5dstruct *v, int time, int var, float data[] );
extern int v5dWriteCompressedGrid( const v5dstruct *v,
int time, int var,
const float *ga, const float *gb,
const void *compdata );
extern int v5dWriteGrid( v5dstruct *v, int time, int var, const float data[] );
#endif
/* Vis5D version 5.1 */
/*
Vis5D system for visualizing five dimensional gridded data sets
Copyright (C) 1990-1997 Bill Hibbard, Brian Paul, Dave Santek,
and Andre Battaiola.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* This configuration file contains options which can be safely
* changed by the user.
*/
#ifndef VIS5D_H
#define VIS5D_H
/*
* Amount of physical RAM in megabytes:
* vis5d normally uses a bounded amount of memory to avoid swapping.
* When the limit is reached, the least-recently-viewed graphics will
* be deallocated. If MBS is set to 0, however, vis5d will use ordinary
* malloc/free and not deallocate graphics (ok for systems with a lot
* of memory (>=128MB)).
*/
/* Default Value: 32 */
#define MBS 128
/* Default topography file: */
#define TOPOFILE "/home/chajpmnt/chajp/ADD/data/EARTH.TOPO"
/* Default map lines files: */
#define WORLDFILE "/home/chajpmnt/chajp/ADD/data/OUTLSUPW"
#define USAFILE "/home/chajpmnt/chajp/ADD/data/OUTLUSAM"
/* Default filename of Tcl startup commands: */
#define TCL_STARTUP_FILE "vis5d.tcl"
/* Default directory to search for user functions: */
#define FUNCTION_PATH "userfuncs"
/* Default animation rate in milliseconds: */
#define ANIMRATE 100
/* Default scale and exponent values for logrithmic vertical coordinate system: */
#define DEFAULT_LOG_SCALE 1012.5
#define DEFAULT_LOG_EXP -7.2
#define DEFAULT_SOUNDFONTNAME "6x12"
/**********************************************************************/
/**********************************************************************/
/*** USERS: DON'T CHANGE ANYTHING BEYOND THIS POINT ***/
/**********************************************************************/
/**********************************************************************/
/*
* Define BIG_GFX to allow larger isosurfaces, contour slices, etc. if
* there's enough memory.
#if MBS==0 || MBS>=128
# define BIG_GFX
#endif
*/
#define BIG_GFX
/*
* Shared by code above and below API:
*/
#define MAX_LABEL 1000
#define MAX_FUNCS 100
#endif
tools.ps : tools.dvi
dvips -o $@ $<
tools.dvi : tools.tex
latex tools.tex
latex tools.tex
latex tools.tex
clean:
rm -f *.aux *.log *.toc *.dvi
realclean: clean
rm -f *.ps
\section{Conversion of FM synchronous file to diachronic format}
Short description is given here, readers must refer to the original documentation on the Meso-NH web site:
``{\sc traitement graphique des fichiers synchrones produits par le mod\`ele
mesonh}, J. Duron''.
\subsection{Synchronous and diachronic formats} \label{diachro_file}
The Meso-NH graphic utility ({\tt diaprog}) works on FM files which are on
diachronic format. A diachronic FM file is either
\begin{itemize}
\item
a file produced during the simulation
which contain time series of self-documented informations
(e.g. file with name CEXP.1.CSEG.000).
An information is one of the following:
\subitem - a
3-dimensional, 2-dimensional, 1-dimensional or 0-dimensional field (eventually
time-averaged, or compressed in one direction): type {\sc cart},
\subitem - a set of vertical profiles at points checking some criteria:
type {\sc mask},
\subitem - spectral coefficients obtained by FFT along the X or Y direction:
type {\sc spxy},
\subitem - pseudo-observations (ground station: type {\sc ssol};
dropsonde: type {\sc drst}; radiosonde: type {\sc rspl};
airborne radar: type {\sc rapl}).
\\
A diachronic file can contains informations of one or several previous types
stored at different time frequency.
For a whole description about the diachronic file type, reader must refer
to the original documentation on the Meso-NH web site:
``{\sc cr\'eation et exploitation de fichiers diachroniques}, J. Duron''.
\end{itemize}
or
\begin{itemize}
\item a `pseudo'-diachronic file resulting of the conversion of a synchronous
file (e.g. with name CEXP.1.CSEG.00n where n$>$0).
Recall that such a file contains all the pronostic fields of the model at one
instant (initial or during the simulation).
When converted it is a 'pseudo'-diachronic file, because it contains only one
instant and one type of diachronic information ({\sc cart}).
The next subsection presents the conversion tool (named \texttt{conv2dia})
to apply to synchronous files, necessary step to use \texttt{diaprog} graphic
tool.
\end{itemize}
\subsection{{\tt conv2dia} tool}
The conversion tool works on files produced by
the initialisation programs ({\sc prep\_pgd, prep\_ideal\_case,
prep\_real\_case}), the model simulation, or the post-processing program
({\tt\sc diag}). It allows to convert one synchronous file onto one diachronic
file, as well as merge several synchronous files with chronological times
(outputs of one run, or files initialised from large-scale model)
onto one diachronic file.
With {\tt conv2dia.elim} tool, you can choose not to convert all the fields of
the input file(s). The pronostic fields at $t-dt$ instant, or at $t$ instant,
or any other fields can be eliminated.
With {\tt conv2dia.select} tool, you have to indicate the fields to select
for conversion.
This is done to reduce the size of the output file.
The output file contains informations whose type is {\sc cart} stored in arrays
with size of {\tt (IIU*IJU*IKU), (IIU*IJU), (IIU*IKU),} or 1.
\subsection{Example}
Only the binary (\textsc{LFI}) part of the input FM files is required
in the current directory (split the FM file with the {\tt fm2deslfi}
script if not).
All characters typed on keyboard are saved in {\tt dirconv.elim} or
{\tt dirconv.select} file, it can be appended and used as input (after being
renamed) for the next call of the tool
\newline (e.g. {\tt conv2dia.elim < dirconv.elim.ex}).
Below is the example of questions when {\tt conv2dia.elim} is invoked.
\small
\begin{tabular}{l}
\\
\\
{\tt ENTER NUMBER OF INPUT FM FILES} \\
{\tt\it 2 } \\
{\tt ENTER FM FILE NAME} \\
{\tt\it CEXP.1.CSEG.001} \\
{\tt ENTER FM FILE NAME} \\
{\tt\it CEXP.1.CSEG.002} \\
{\tt ENTER DIACHRONIC FILE NAME} \\
{\tt\it CEXP.1.CSEG.1-2.dia} \\
{\tt DELETION OF PARAMETERS AT TIME t-dt ? (enter 1) } \\
{\tt DELETION OF PARAMETERS AT TIME t ? (enter 2) } \\
{\tt NO DELETION ? (enter 0) } \\
{\tt\it 2 } \\
{\tt Do you want to suppress others parameters ? (y/n) }\\
{\tt\it y } \\
{\tt Enter their names in UPPERCASE (1/1 line) }\\
{\tt End by END}\\
{\tt\it DTHCONV } \\
{\tt\it DRVCONV } \\
{\tt\it END } \\
\end{tabular}
\normalsize
This diff is collapsed.
This diff is collapsed.
\section{Introduction}
After initialisation, run of the model or computation of diagnostics,
output Meso-NH files can be convert into other formats of files.
The present documentation aims at describ the differents tools which can be
applied to the binary part of FM files (their suffix is {\bf .lfi}).
Most of these tools can be run on the user local
computer (Linux PC or HP workstation).
\\
First, the compression tool \texttt{lfiz} and the conversion
tool \texttt{conv2dia} dealing with FM files (synchronous and diachronic)
as input and output, are described.
The next sections concern tools dealing with other formats than
FM: conversions with \texttt{lfi2cdf}, \texttt{lfi2grb} and \texttt{lfi2v5d}.
A set of tools for reading diachronic FM files and dealing with diachronic
informations is presented: \texttt{extractdia}, \texttt{mesonh2obs} and
\texttt{obs2mesonh} (the 2 latest aim at help users to compare MesoNH outputs to
observations).
\\
The figure \ref{fig:fic1} shows when a FM file is either \underline{synchronous}
(contains the values of all the fields corresponding to the same instant of the
simulation) or \underline{diachronic} (contains time series of some fields
obtained during the run of the model).
Then the figure \ref{fig:toolstab} resumes the tools which can be applied to a
FM file according its type, one of the two previous ones. \\
\begin{figure}[htb]
\psfig{file=fic1.eps,width=17cm}
\caption{Type of FM files after a MesoNH program\label{fig:fic1}}
\end{figure}
\begin{figure}[htb]
\centerline{\psfig{file=toolstab.eps,width=17cm} }
\caption{Which tools on FM files? \label{fig:toolstab}}
\end{figure}
\section{Conversion to NetCDF files}
\subsection{{\tt lfi2cdf} tool}
The \texttt{lfi2cdf} tool converts the binary part (or LFI file) of a
FM file (synchronous or diachronic) into a NetCDF file. All the fields
(or more precisely all the LFI articles) contained in the input LFI file
are copied to the NetCDF output file with their values unchanged. As
a LFI article does not hold any information on the variable, the tool
tries to describe the corresponding NetCDF variable by using~:
\begin{itemize}
\item 3 LFI articles: \texttt{IMAX, JMAX,} and \texttt{KMAX}
if they are available in the LFI input file. These articles may
provide the NetCDF dimensions \texttt{DIMX, DIMY,} and \texttt{DIMZ}
of an array variable. If these variables are not available in the
input file, the tool treats each array variable as a 1D array.
\item a small database implemented as a structure array in the
\texttt{lfi2cdf} source file \texttt{fieldtype.f90}. This array
holds the type (\texttt{REAL, INTEGER, LOGICAL}\ldots) of every
common LFI article. When an article is not present in this database,
its name is displayed on \texttt{stdout} by the running tool, and
the corresponding values are always considered as \texttt{REAL}
values. A new LFI article type description can be easily added in
the \texttt{fieldtype.f90} source file and the tool must be then
recompiled.
\end{itemize}
\subsubsection{Usage}
The binary part of the FM file is required in the current directory.
The following commands convert a file \texttt{myfile.lfi} from LFI to NetCDF:
\begin{verbatim}
lfi2cdf myfile.lfi
\end{verbatim}
or
\begin{verbatim}
lfi2cdf myfile
\end{verbatim}
\noindent The output NetCDF file is named:
\texttt{myfile.cdf}.
%myfile{\bf .cdf}.
It can easily be manipulated by NetCDF tools\footnote{see
freely available NetCDF software at http://www.unidata.ucar.edu/packages/netcdf/software.html} like
\texttt{ncdump}, \texttt{ncview}, or \texttt{NCO} operators.\\
\noindent In the same way, you will convert a NetCDF
file \texttt{myfile.cdf} back to LFI format by typing:
\begin{verbatim}
cdf2lfi myfile.cdf
\end{verbatim}
or
\begin{verbatim}
cdf2lfi myfile
\end{verbatim}
The output LFI file is then named: \texttt{myfile.lfi}
\subsection{{\tt extractdia} tool}
The \texttt{extractdia} tool converts a diachronic FM file into a NetCDF file after an extraction of a list of fields and an optional extraction of a sub-domain. See the section \ref{extractdia}.
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "tools"
%%% End:
This diff is collapsed.
\section{Compression of FM files}
A specific compression tool has been developed for FM files. This
tool, called {\tt lfiz}, was first devoted for files that will be
explored by the graphic utility {\tt diaprog}. In fact, it is also
used for files used during a simulation (initial and coupling files)
to reduce the data storage. Some information of how the compression
works is given here, its execution is particularly easy.
\subsection{{\tt lfiz} tool}
The \texttt{lfiz} tool works on the binary part (LFI file) of a FM
file, synchronous or diachronic. It is a lossy compression tool.
The compressed articles are exclusively the 2-dimensional or
3-dimensional \texttt{REAL} fields. When dealing with 3D fields the tool works
with each 2D plane on every vertical level. The initial values stored
with 64-bit \texttt{REAL} precision are first converted into 32-bit
\texttt{REAL} precision and then compressed by mapping the 32-bit
real values upon 16-bit integer values (with a possible isolation of
extrema values). The better compression is
achieved for fields with small value range. For fields with missing
value (e.g. 2-dimensional fields with land-sea mask), the extremum
value is excluded and the compression is done on significant values of
the field. The minimum compression ratio is 4 for each 2D or 3D
\texttt{REAL} compressed field.
\subsection{{\tt unlfiz} tool}
The \texttt{unlfiz} tool will restore the 64-bit \texttt{REAL} value size to all
the compressed LFI articles. However, each previously compressed article
will gain no more than a 32-bit \texttt{REAL} precision because of the lossy
technique involved above.
\subsection{Usage}
The binary part of the FM file is required in the current
directory. To compress the file \texttt{myfile.lfi}, you can type:
\begin{verbatim}
lfiz myfile.lfi
\end{verbatim}
\noindent This will produce the compressed file \texttt{myfile.Z.lfi}\\
\noindent In the same way, to uncompress the file \texttt{myfile.Z.lfi}, you can
type:
\begin{verbatim}
unlfiz myfile.Z.lfi
\end{verbatim}
\noindent The output file \texttt{myfile.lfi} is a valid LFI file but the LFI
articles previously compressed are 64-bit \texttt{REAL} with no more than 32-bit
\texttt{REAL} precision.
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "tools"
%%% End:
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
&NAM_STO_FILE CFILES(1)='AR40_mc2_19990921.00d.Z',
CFILES(2)='AR40_mc2_19990920.12d.Z',
CFILES(3)='AR40_mc2_19990920.00d.Z',
CFILES(4)='AR40_mc2_19990919.12d.Z',
CFILES(5)='AR40_mc2_19990919.00d.Z' /
&NAM_FIELD CFIELD_LAG(1)='THM',
CFIELD_LAG(2)='RVM' /
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.