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
/* v5d.c */
/* Vis5D version 5.1 */
/*
Vis5D system for visualizing five dimensional gridded data sets
Copyright (C) 1990 - 1997 Bill Hibbard, Johan Kellum, 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 should be updated when the file version changes */
#define FILE_VERSION "4.3"
/*
* New grid file format for VIS-5D:
*
* The header is a list of tagged items. Each item has 3 parts:
* 1. A tag which is a 4-byte integer identifying the type of item.
* 2. A 4-byte integer indicating how many bytes of data follow.
* 3. The binary data.
*
* If we need to add new information to a file header we just create a
* new tag and add the code to read/write the information.
*
* If we're reading a header and find an unknown tag, we can use the
* length field to skip ahead to the next tag. Therefore, the file
* format is forward (and backward) compatible.
*
* Grid data is stored as either:
* 1-byte unsigned integers (255=missing)
* 2-byte unsigned integers (65535=missing)
* 4-byte IEEE floats ( >1.0e30 = missing)
*
* All numeric values are stored in big endian order. All floating point
* values are in IEEE format.
*/
/*
* Updates:
*
* April 13, 1995, brianp
* finished Cray support for 2-byte and 4-byte compress modes
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "binio.h"
#include "v5d.h"
#include "vis5d.h"
#ifndef SEEK_SET
# define SEEK_SET 0
#endif
#ifndef SEEK_CUR
# define SEEK_CUR 1
#endif
#ifndef SEEK_END
# define SEEK_END 2
#endif
/*
* Currently defined tags:
* Note: the notation a[i] doesn't mean a is an array of i elements,
* rather it just refers to the ith element of a[].
*
* Tags marked as PHASED OUT should be readable but are no longer written.
* Old tag numbers can't be reused!
*
*/
/* TAG NAME VALUE DATA (comments) */
/*----------------------------------------------------------------------*/
#define TAG_ID 0x5635440a /* hex encoding of "V5D\n" */
/* general stuff 1000+ */
#define TAG_VERSION 1000 /* char*10 FileVersion */
#define TAG_NUMTIMES 1001 /* int*4 NumTimes */
#define TAG_NUMVARS 1002 /* int*4 NumVars */
#define TAG_VARNAME 1003 /* int*4 var; char*10 VarName[var] */
#define TAG_NR 1004 /* int*4 Nr */
#define TAG_NC 1005 /* int*4 Nc */
#define TAG_NL 1006 /* int*4 Nl (Nl for all vars) */
#define TAG_NL_VAR 1007 /* int*4 var; int*4 Nl[var] */
#define TAG_LOWLEV_VAR 1008 /* int*4 var; int*4 LowLev[var] */
#define TAG_TIME 1010 /* int*4 t; int*4 TimeStamp[t] */
#define TAG_DATE 1011 /* int*4 t; int*4 DateStamp[t] */
#define TAG_MINVAL 1012 /* int*4 var; real*4 MinVal[var] */
#define TAG_MAXVAL 1013 /* int*4 var; real*4 MaxVal[var] */
#define TAG_COMPRESS 1014 /* int*4 CompressMode; (#bytes/grid)*/
#define TAG_UNITS 1015 /* int *4 var; char*20 Units[var] */
/* vertical coordinate system 2000+ */
#define TAG_VERTICAL_SYSTEM 2000 /* int*4 VerticalSystem */
#define TAG_VERT_ARGS 2100 /* int*4 n; real*4 VertArgs[0..n-1]*/
#define TAG_BOTTOMBOUND 2001 /* real*4 BottomBound (PHASED OUT) */
#define TAG_LEVINC 2002 /* real*4 LevInc (PHASED OUT) */
#define TAG_HEIGHT 2003 /* int*4 l; real*4 Height[l] (PHASED OUT) */
/* projection 3000+ */
#define TAG_PROJECTION 3000 /* int*4 projection: */
/* 0 = generic linear */
/* 1 = cylindrical equidistant */
/* 2 = Lambert conformal/Polar Stereo */
/* 3 = rotated equidistant */
#define TAG_PROJ_ARGS 3100 /* int *4 n; real*4 ProjArgs[0..n-1] */
#define TAG_NORTHBOUND 3001 /* real*4 NorthBound (PHASED OUT) */
#define TAG_WESTBOUND 3002 /* real*4 WestBound (PHASED OUT) */
#define TAG_ROWINC 3003 /* real*4 RowInc (PHASED OUT) */
#define TAG_COLINC 3004 /* real*4 ColInc (PHASED OUT) */
#define TAG_LAT1 3005 /* real*4 Lat1 (PHASED OUT) */
#define TAG_LAT2 3006 /* real*4 Lat2 (PHASED OUT) */
#define TAG_POLE_ROW 3007 /* real*4 PoleRow (PHASED OUT) */
#define TAG_POLE_COL 3008 /* real*4 PoleCol (PHASED OUT) */
#define TAG_CENTLON 3009 /* real*4 CentralLon (PHASED OUT) */
#define TAG_CENTLAT 3010 /* real*4 CentralLat (PHASED OUT) */
#define TAG_CENTROW 3011 /* real*4 CentralRow (PHASED OUT) */
#define TAG_CENTCOL 3012 /* real*4 CentralCol (PHASED OUT) */
#define TAG_ROTATION 3013 /* real*4 Rotation (PHASED OUT) */
#define TAG_END 9999
/**********************************************************************/
/***** Miscellaneous Functions *****/
/**********************************************************************/
float pressure_to_height(float pressure)
{
return (float) DEFAULT_LOG_EXP * log((double) pressure / DEFAULT_LOG_SCALE);
}
float height_to_pressure(float height)
{
return (float) DEFAULT_LOG_SCALE * exp((double) height / DEFAULT_LOG_EXP);
}
/*
* Return current file position.
* Input: f - file descriptor
*/
static off_t ltell( int f )
{
return lseek( f, 0, SEEK_CUR );
}
/*
* Copy up to maxlen characters from src to dst stopping upon whitespace
* in src. Terminate dst with null character.
* Return: length of dst.
*/
static int copy_string2( char *dst, const char *src, int maxlen )
{
int i;
for (i=0;i<maxlen;i++) dst[i] = src[i];
for (i=maxlen-1; i>=0; i--) {
if (dst[i]==' ' || i==maxlen-1) dst[i] = 0;
else break;
}
return strlen(dst);
}
/*
* Copy up to maxlen characters from src to dst stopping upon whitespace
* in src. Terminate dst with null character.
* Return: length of dst.
*/
static int copy_string( char *dst, const char *src, int maxlen )
{
int i;
for (i=0;i<maxlen;i++) {
if (src[i]==' ' || i==maxlen-1) {
dst[i] = 0;
break;
}
else {
dst[i] = src[i];
}
}
return i;
}
/*
* Convert a date from YYDDD format to days since Jan 1, 1900.
*/
int v5dYYDDDtoDays( int yyddd )
{
int iy, id, idays;
iy = yyddd / 1000;
id = yyddd - 1000*iy;
if (iy < 50) iy += 100; /* WLH 31 July 96 << 31 Dec 99 */
idays = 365*iy + (iy-1)/4 + id;
return idays;
}
/*
* Convert a time from HHMMSS format to seconds since midnight.
*/
int v5dHHMMSStoSeconds( int hhmmss )
{
int h, m, s;
h = hhmmss / 10000;
m = (hhmmss / 100) % 100;
s = hhmmss % 100;
return s + m*60 + h*60*60;
}
/*
* Convert a day since Jan 1, 1900 to YYDDD format.
*/
int v5dDaysToYYDDD( int days )
{
int iy, id, iyyddd;
iy = (4*days)/1461;
id = days-(365*iy+(iy-1)/4);
if (iy > 99) iy = iy - 100; /* WLH 31 July 96 << 31 Dec 99 */
/* iy = iy + 1900; is the right way to fix this, but requires
changing all places where dates are printed - procrastinate */
iyyddd = iy*1000+id;
return iyyddd;
}
/*
* Convert a time in seconds since midnight to HHMMSS format.
*/
int v5dSecondsToHHMMSS( int seconds )
{
int hh, mm, ss;
hh = seconds / (60*60);
mm = (seconds / 60) % 60;
ss = seconds % 60;
return hh*10000 + mm * 100 + ss;
}
void v5dPrintStruct( const v5dstruct *v )
{
static char day[7][10] = { "Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday" };
int time, var, i;
int maxnl;
maxnl = 0;
for (var=0;var<v->NumVars;var++) {
if (v->Nl[var]+v->LowLev[var]>maxnl) {
maxnl = v->Nl[var]+v->LowLev[var];
}
}
if (v->FileFormat==0) {
if (v->FileVersion[0] == 0) {
printf("File format: v5d version: (4.0 or 4.1)\n");
}
else {
printf("File format: v5d version: %s\n", v->FileVersion);
}
}
else {
printf("File format: comp5d (VIS-5D 3.3 or older)\n");
}
if (v->CompressMode==1) {
printf("Compression: 1 byte per gridpoint.\n");
}
else {
printf("Compression: %d bytes per gridpoint.\n", v->CompressMode);
}
printf("header size=%d\n", v->FirstGridPos);
printf("sizeof(v5dstruct)=%d\n", sizeof(v5dstruct) );
printf("\n");
printf("NumVars = %d\n", v->NumVars );
printf("Var Name Units Rows Cols Levels LowLev MinVal MaxVal\n");
for (var=0;var<v->NumVars;var++) {
printf("%3d %-10s %-10s %3d %3d %3d %3d",
var+1, v->VarName[var], v->Units[var],
v->Nr, v->Nc, v->Nl[var], v->LowLev[var] );
if (v->MinVal[var] > v->MaxVal[var]) {
printf(" MISSING MISSING\n");
}
else {
printf(" %-12g %-12g\n", v->MinVal[var], v->MaxVal[var] );
}
}
printf("\n");
printf("NumTimes = %d\n", v->NumTimes );
printf("Step Date(YYDDD) Time(HH:MM:SS) Day\n");
for (time=0;time<v->NumTimes;time++) {
int i = v->TimeStamp[time];
printf("%3d %05d %5d:%02d:%02d %s\n",
time+1,
v->DateStamp[time],
i/10000, (i/100)%100, i%100,
day[ v5dYYDDDtoDays(v->DateStamp[time]) % 7 ]);
}
printf("\n");
switch (v->VerticalSystem) {
case 0:
printf("Generic linear vertical coordinate system:\n");
printf("\tBottom Bound: %f\n", v->VertArgs[0] );
printf("\tIncrement between levels: %f\n", v->VertArgs[1] );
break;
case 1:
printf("Equally spaced levels in km:\n");
printf("\tBottom Bound: %f\n", v->VertArgs[0] );
printf("\tIncrement: %f\n", v->VertArgs[1] );
break;
case 2:
printf("Unequally spaced levels in km:\n");
printf("Level\tHeight(km)\n");
for (i=0;i<maxnl;i++) {
printf("%3d %10.3f\n", i+1, v->VertArgs[i] );
}
break;
case 3:
printf("Unequally spaced levels in mb:\n");
printf("Level\tPressure(mb)\n");
for (i=0;i<maxnl;i++) {
printf("%3d %10.3f\n", i+1, height_to_pressure(v->VertArgs[i]) );
}
break;
default:
printf("Bad VerticalSystem value: %d\n", v->VerticalSystem );
}
printf("\n");
switch (v->Projection) {
case 0:
printf("Generic linear projection:\n");
printf("\tNorth Boundary: %f\n", v->ProjArgs[0] );
printf("\tWest Boundary: %f\n", v->ProjArgs[1] );
printf("\tRow Increment: %f\n", v->ProjArgs[2] );
printf("\tColumn Increment: %f\n", v->ProjArgs[3] );
break;
case 1:
printf("Cylindrical Equidistant projection:\n");
printf("\tNorth Boundary: %f degrees\n", v->ProjArgs[0] );
printf("\tWest Boundary: %f degrees\n", v->ProjArgs[1] );
printf("\tRow Increment: %f degrees\n", v->ProjArgs[2] );
printf("\tColumn Increment: %f degrees\n", v->ProjArgs[3] );
/*
printf("\tSouth Boundary: %f degrees\n",
v->NorthBound - v->RowInc * (v->Nr-1) );
printf("\tEast Boundary: %f degrees\n",
v->WestBound - v->ColInc * (v->Nc-1) );
*/
break;
case 2:
printf("Lambert Conformal projection:\n");
printf("\tStandard Latitude 1: %f\n", v->ProjArgs[0] );
printf("\tStandard Latitude 2: %f\n", v->ProjArgs[1] );
printf("\tNorth/South Pole Row: %f\n", v->ProjArgs[2] );
printf("\tNorth/South Pole Column: %f\n", v->ProjArgs[3] );
printf("\tCentral Longitude: %f\n", v->ProjArgs[4] );
printf("\tColumn Increment: %f km\n", v->ProjArgs[5] );
break;
case 3:
printf("Stereographic:\n");
printf("\tCenter Latitude: %f\n", v->ProjArgs[0] );
printf("\tCenter Longitude: %f\n", v->ProjArgs[1] );
printf("\tCenter Row: %f\n", v->ProjArgs[2] );
printf("\tCenter Column: %f\n", v->ProjArgs[3] );
printf("\tColumn Spacing: %f\n", v->ProjArgs[4] );
break;
case 4:
/* WLH 4-21-95 */
printf("Rotated equidistant projection:\n");
printf("\tLatitude of grid(0,0): %f\n", v->ProjArgs[0] );
printf("\tLongitude of grid(0,0): %f\n", v->ProjArgs[1] );
printf("\tRow Increment: %f degress\n", v->ProjArgs[2] );
printf("\tColumn Increment: %f degrees\n", v->ProjArgs[3] );
printf("\tCenter Latitude: %f\n", v->ProjArgs[4] );
printf("\tCenter Longitude: %f\n", v->ProjArgs[5] );
printf("\tRotation: %f degrees\n", v->ProjArgs[6] );
break;
default:
printf("Bad projection number: %d\n", v->Projection );
}
}
/*
* Compute the location of a compressed grid within a file.
* Input: v - pointer to v5dstruct describing the file header.
* time, var - which timestep and variable.
* Return: file offset in bytes
*/
static int grid_position( const v5dstruct *v, int time, int var )
{
int pos, i;
assert( time >= 0 );
assert( var >= 0 );
assert( time < v->NumTimes );
assert( var < v->NumVars );
pos = v->FirstGridPos + time * v->SumGridSizes;
for (i=0;i<var;i++) {
pos += v->GridSize[i];
}
return pos;
}
/*
* Compute the ga and gb (de)compression values for a grid.
* Input: nr, nc, nl - size of grid
* data - the grid data
* ga, gb - arrays to store results.
* minval, maxval - pointer to floats to return min, max values
* compressmode - 1, 2 or 4 bytes per grid point
* Output: ga, gb - the (de)compression values
* minval, maxval - the min and max grid values
* Side effect: the MinVal[var] and MaxVal[var] fields in g may be
* updated with new values.
*/
static void compute_ga_gb( int nr, int nc, int nl,
const float data[], int compressmode,
float ga[], float gb[],
float *minval, float *maxval )
{
#ifdef SIMPLE_COMPRESSION
/*
* Compute ga, gb values for whole grid.
*/
int i, lev, allmissing, num;
float min, max, a, b;
min = 1.0e30;
max = -1.0e30;
num = nr * nc * nl;
allmissing = 1;
for (i=0;i<num;i++) {
if (!IS_MISSING(data[i])) {
if (data[i]<min) min = data[i];
if (data[i]>max) max = data[i];
allmissing = 0;
}
}
if (allmissing) {
a = 1.0;
b = 0.0;
}
else {
a = (max-min) / 254.0;
b = min;
}
/* return results */
for (i=0;i<nl;i++) {
ga[i] = a;
gb[i] = b;
}
*minval = min;
*maxval = max;
#else
/*
* Compress grid on level-by-level basis.
*/
# define SMALLVALUE -1.0e30
# define BIGVALUE 1.0e30
# define ABS(x) ( ((x) < 0.0) ? -(x) : (x) )
float gridmin, gridmax;
float levmin[MAXLEVELS], levmax[MAXLEVELS];
float d[MAXLEVELS], dmax;
float ival, mval;
int j, k, lev, nrnc;
nrnc = nr * nc;
/* find min and max for each layer and the whole grid */
gridmin = BIGVALUE;
gridmax = SMALLVALUE;
j = 0;
for (lev=0;lev<nl;lev++) {
float ave, var;
float min, max;
min = BIGVALUE;
max = SMALLVALUE;
ave = 0.0;
var = 0.0;
for (k=0;k<nrnc;k++) {
if (!IS_MISSING(data[j]) && data[j]<min)
min = data[j];
if (!IS_MISSING(data[j]) && data[j]>max)
max = data[j];
j++;
}
if (min<gridmin)
gridmin = min;
if (max>gridmax)
gridmax = max;
levmin[lev] = min;
levmax[lev] = max;
}
/* WLH 2-2-95 */
#ifdef KLUDGE
/* if the grid minimum is within delt of 0.0, fudge all values */
/* within delt of 0.0 to delt, and recalculate mins and maxes */
{
float delt;
int nrncnl = nrnc * nl;
delt = (gridmax - gridmin)/100000.0;
if ( ABS(gridmin) < delt && gridmin!=0.0 && compressmode != 4 ) {
float min, max;
for (j=0; j<nrncnl; j++) {
if (!IS_MISSING(data[j]) && data[j]<delt)
data[j] = delt;
}
/* re-calculate min and max for each layer and the whole grid */
gridmin = delt;
for (lev=0;lev<nl;lev++) {
if (ABS(levmin[lev]) < delt)
levmin[lev] = delt;
if (ABS(levmax[lev]) < delt)
levmax[lev] = delt;
}
}
}
#endif
/* find d[lev] and dmax = MAX( d[0], d[1], ... d[nl-1] ) */
dmax = 0.0;
for (lev=0;lev<nl;lev++) {
if (levmin[lev]>=BIGVALUE && levmax[lev]<=SMALLVALUE) {
/* all values in the layer are MISSING */
d[lev] = 0.0;
}
else {
d[lev] = levmax[lev]-levmin[lev];
}
if (d[lev]>dmax)
dmax = d[lev];
}
/*** Compute ga (scale) and gb (bias) for each grid level */
if (dmax==0.0) {
/*** Special cases ***/
if (gridmin==gridmax) {
/*** whole grid is of same value ***/
for (lev=0; lev<nl; lev++) {
ga[lev] = gridmin;
gb[lev] = 0.0;
}
}
else {
/*** every layer is of a single value ***/
for (lev=0; lev<nl; lev++) {
ga[lev] = levmin[lev];
gb[lev] = 0.0;
}
}
}
else {
/*** Normal cases ***/
if (compressmode == 1) {
#define ORIGINAL
#ifdef ORIGINAL
ival = dmax / 254.0;
mval = gridmin;
for (lev=0; lev<nl; lev++) {
ga[lev] = ival;
gb[lev] = mval + ival * (int) ( (levmin[lev]-mval) / ival );
}
#else
for (lev=0; lev<nl; lev++) {
if (d[lev]==0.0) {
ival = 1.0;
}
else {
ival = d[lev] / 254.0;
}
ga[lev] = ival;
gb[lev] = levmin[lev];
}
#endif
}
else if (compressmode == 2) {
ival = dmax / 65534.0;
mval = gridmin;
for (lev=0; lev<nl; lev++) {
ga[lev] = ival;
gb[lev] = mval + ival * (int) ( (levmin[lev]-mval) / ival );
}
}
else {
assert( compressmode==4 );
for (lev=0; lev<nl; lev++) {
ga[lev] = 1.0;
gb[lev] = 0.0;
}
}
}
/* update min, max values */
*minval = gridmin;
*maxval = gridmax;
#endif
}
/*
* Compress a 3-D grid from floats to 1-byte unsigned integers.
* Input: nr, nc, nl - size of grid
* compressmode - 1, 2 or 4 bytes per grid point
* data - array of [nr*nc*nl] floats
* compdata - pointer to array of [nr*nc*nl*compressmode] bytes
* to put results into.
* ga, gb - pointer to arrays to put ga and gb decompression values
* minval, maxval - pointers to float to return min & max values
* Output: compdata - the compressed grid data
* ga, gb - the decompression values
* minval, maxval - the min and max grid values
*/
void v5dCompressGrid( int nr, int nc, int nl, int compressmode,
const float data[],
void *compdata, float ga[], float gb[],
float *minval, float *maxval )
{
int nrnc = nr * nc;
int nrncnl = nr * nc * nl;
V5Dubyte *compdata1 = (V5Dubyte *) compdata;
V5Dushort *compdata2 = (V5Dushort *) compdata;
/* compute ga, gb values */
compute_ga_gb( nr, nc, nl, data, compressmode, ga, gb, minval, maxval );
/* compress the data */
if (compressmode==1) {
int i, lev, p;
p = 0;
for (lev=0;lev<nl;lev++) {
float one_over_a, b;
/* WLH 5 Nov 98
b = gb[lev] - 0.0001;
*/
/* WLH 5 Nov 98 */
b = gb[lev];
/* subtract an epsilon so the int((d-b)/a) */
/* expr below doesn't get mis-truncated. */
if (ga[lev]==0.0) {
one_over_a = 1.0;
}
else {
one_over_a = 1.0 / ga[lev];
}
for (i=0;i<nrnc;i++,p++) {
if (IS_MISSING(data[p])) {
compdata1[p] = 255;
}
else {
/* MJK 1.19.99
compdata1[p] = (V5Dubyte) (int) ((data[p]-b) * one_over_a);
*/
compdata1[p] = (V5Dubyte) rint((data[p]-b) * one_over_a);
if (compdata1[p] >= 255){
compdata1[p] = (V5Dubyte) (int) (255.0 - .0001);
}
}
}
}
}
else if (compressmode == 2) {
int i, lev, p;
p = 0;
for (lev=0;lev<nl;lev++) {
float one_over_a, b;
/* WLH 5 Nov 98
b = gb[lev] - 0.0001;
*/
/* WLH 5 Nov 98 */
b = gb[lev];
if (ga[lev]==0.0) {
one_over_a = 1.0;
}
else {
one_over_a = 1.0 / ga[lev];
}
#ifdef _CRAY
/* this is tricky because sizeof(V5Dushort)==8, not 2 */
for (i=0;i<nrnc;i++,p++) {
V5Dushort compvalue;
if (IS_MISSING(data[p])) {
compvalue = 65535;
}
else {
/* MJK 3.2.99
compvalue = (V5Dushort) (int) ((data[p]-b) * one_over_a);
*/
compvalue = (V5Dushort) rint((data[p]-b) * one_over_a);
}
compdata1[p*2+0] = compvalue >> 8; /* upper byte */
compdata1[p*2+1] = compvalue & 0xffu; /* lower byte */
}
#else
for (i=0;i<nrnc;i++,p++) {
if (IS_MISSING(data[p])) {
compdata2[p] = 65535;
}
else {
compdata2[p] = (V5Dushort) rint((data[p]-b) * one_over_a);
/*
compdata2[p] = (V5Dushort) (int) ((data[p]-b) * one_over_a);
*/
/* MJK 3.24.99 I put this here so if the value is close
to the missing value and get's rounded up it won't come out
as missing data */
if (compdata2[p] == 65535){
compdata2[p] = 65534;
}
}
}
/* TODO: byte-swapping on little endian??? */
#endif
}
}
else {
/* compressmode==4 */
#ifdef _CRAY
cray_to_ieee_array( compdata, data, nrncnl );
#else
/* other machines: just copy 4-byte IEEE floats */
assert( sizeof(float)==4 );
memcpy( compdata, data, nrncnl*4 );
/* TODO: byte-swapping on little endian??? */
#endif
}
}
/*
* Decompress a 3-D grid from 1-byte integers to 4-byte floats.
* Input: nr, nc, nl - size of grid
* compdata - array of [nr*nr*nl*compressmode] bytes
* ga, gb - arrays of decompression factors
* compressmode - 1, 2 or 4 bytes per grid point
* data - address to put decompressed values
* Output: data - uncompressed floating point data values
*/
void v5dDecompressGrid( int nr, int nc, int nl, int compressmode,
void *compdata, float ga[], float gb[],
float data[] )
{
int nrnc = nr * nc;
int nrncnl = nr * nc * nl;
V5Dubyte *compdata1 = (V5Dubyte *) compdata;
V5Dushort *compdata2 = (V5Dushort *) compdata;
if (compressmode == 1) {
int p, i, lev;
p = 0;
for (lev=0;lev<nl;lev++) {
float a = ga[lev];
float b = gb[lev];
/* WLH 2-2-95 */
float d, aa;
int id;
if (a > 0.0000000001) {
d = b / a;
id = floor(d);
d = d - id;
aa = a * 0.000001;
}
else {
id = 1;
}
if (-254 <= id && id <= 0 && d < aa) {
for (i=0;i<nrnc;i++,p++) {
if (compdata1[p]==255) {
data[p] = MISSING;
}
else {
data[p] = (float) (int) compdata1[p] * a + b;
if (fabs(data[p]) < aa) data[p] = aa;
}
}
}
else {
for (i=0;i<nrnc;i++,p++) {
if (compdata1[p]==255) {
data[p] = MISSING;
}
else {
data[p] = (float) (int) compdata1[p] * a + b;
}
}
}
/* end of WLH 2-2-95 */
}
}
else if (compressmode == 2) {
int p, i, lev;
p = 0;
for (lev=0;lev<nl;lev++) {
float a = ga[lev];
float b = gb[lev];
#ifdef _CRAY
/* this is tricky because sizeof(V5Dushort)==8, not 2 */
for (i=0;i<nrnc;i++,p++) {
int compvalue;
compvalue = (compdata1[p*2] << 8) | compdata1[p*2+1];
if (compvalue==65535) {
data[p] = MISSING;
}
else {
data[p] = (float) compvalue * a + b;
}
}
#else
/* sizeof(V5Dushort)==2! */
for (i=0;i<nrnc;i++,p++) {
if (compdata2[p]==65535) {
data[p] = MISSING;
}
else {
data[p] = (float) (int) compdata2[p] * a + b;
}
}
#endif
}
}
else {
/* compressmode==4 */
#ifdef _CRAY
ieee_to_cray_array( data, compdata, nrncnl );
#else
/* other machines: just copy 4-byte IEEE floats */
assert( sizeof(float)==4 );
memcpy( data, compdata, nrncnl*4 );
#endif
}
}
/*
* Return the size (in bytes) of the 3-D grid specified by time and var.
* Input: v - pointer to v5dstruct describing the file
* time, var - which timestep and variable
* Return: number of data points.
*/
int v5dSizeofGrid( const v5dstruct *v, int time, int var )
{
return v->Nr * v->Nc * v->Nl[var] * v->CompressMode;
}
/*
* Initialize a v5dstructure to reasonable initial values.
* Input: v - pointer to v5dstruct.
*/
void v5dInitStruct( v5dstruct *v )
{
int i;
/* set everything to zero */
memset( v, 0, sizeof(v5dstruct) );
/* special cases */
v->Projection = -1;
v->VerticalSystem = -1;
for (i=0;i<MAXVARS;i++) {
v->MinVal[i] = MISSING;
v->MaxVal[i] = -MISSING;
v->LowLev[i] = 0;
}
/* set file version */
strcpy(v->FileVersion, FILE_VERSION);
v->CompressMode = 1;
v->FileDesc = -1;
}
/*
* Return a pointer to a new, initialized v5dstruct.
*/
v5dstruct *v5dNewStruct( void )
{
v5dstruct *v;
v = (v5dstruct *) malloc( sizeof(v5dstruct) );
if (v) {
v5dInitStruct(v);
}
return v;
}
/*
* Free an initialized v5dstruct. (Todd Plessel)
*/
void v5dFreeStruct( v5dstruct* v )
{
/*assert( v5dVerifyStruct( v ) );*/
free( v );
v = 0;
}
/*
* Do some checking that the information in a v5dstruct is valid.
* Input: v - pointer to v5dstruct
* Return: 1 = g is ok, 0 = g is invalid
*/
int v5dVerifyStruct( const v5dstruct *v )
{
int var, i, invalid, maxnl;
invalid = 0;
if (!v)
return 0;
/* Number of variables */
if (v->NumVars<0) {
printf("Invalid number of variables: %d\n", v->NumVars );
invalid = 1;
}
else if (v->NumVars>MAXVARS) {
printf("Too many variables: %d (Maximum is %d)\n",
v->NumVars, MAXVARS);
invalid = 1;
}
/* Variable Names */
for (i=0;i<v->NumVars;i++) {
if (v->VarName[i][0]==0) {
printf("Missing variable name: VarName[%d]=\"\"\n", i );
invalid = 1;
}
}
/* Number of timesteps */
if (v->NumTimes<0) {
printf("Invalid number of timesteps: %d\n", v->NumTimes );
invalid = 1;
}
else if (v->NumTimes>MAXTIMES) {
printf("Too many timesteps: %d (Maximum is %d)\n",
v->NumTimes, MAXTIMES );
invalid = 1;
}
/* Make sure timestamps are increasing */
for (i=1;i<v->NumTimes;i++) {
int date0 = v5dYYDDDtoDays( v->DateStamp[i-1] );
int date1 = v5dYYDDDtoDays( v->DateStamp[i] );
int time0 = v5dHHMMSStoSeconds( v->TimeStamp[i-1] );
int time1 = v5dHHMMSStoSeconds( v->TimeStamp[i] );
if (time1<=time0 && date1<=date0) {
printf("Timestamp for step %d must be later than step %d\n", i, i-1);
invalid = 1;
}
}
/* Rows */
if (v->Nr<2) {
printf("Too few rows: %d (2 is minimum)\n", v->Nr );
invalid = 1;
}
else if (v->Nr>MAXROWS) {
printf("Too many rows: %d (%d is maximum)\n", v->Nr, MAXROWS );
invalid = 1;
}
/* Columns */
if (v->Nc<2) {
printf("Too few columns: %d (2 is minimum)\n", v->Nc );
invalid = 1;
}
else if (v->Nc>MAXCOLUMNS) {
printf("Too many columns: %d (%d is maximum)\n", v->Nc, MAXCOLUMNS );
invalid = 1;
}
/* Levels */
maxnl = 0;
for (var=0;var<v->NumVars;var++) {
if (v->LowLev[var] < 0) {
printf("Low level cannot be negative for var %s: %d\n",
v->VarName[var], v->LowLev[var] );
invalid = 1;
}
if (v->Nl[var]<1) {
printf("Too few levels for var %s: %d (1 is minimum)\n",
v->VarName[var], v->Nl[var] );
invalid = 1;
}
if (v->Nl[var]+v->LowLev[var]>MAXLEVELS) {
printf("Too many levels for var %s: %d (%d is maximum)\n",
v->VarName[var], v->Nl[var]+v->LowLev[var], MAXLEVELS );
invalid = 1;
}
if (v->Nl[var]+v->LowLev[var]>maxnl) {
maxnl = v->Nl[var]+v->LowLev[var];
}
}
if (v->CompressMode != 1 && v->CompressMode != 2 && v->CompressMode != 4) {
printf("Bad CompressMode: %d (must be 1, 2 or 4)\n", v->CompressMode );
invalid = 1;
}
switch (v->VerticalSystem) {
case 0:
case 1:
if (v->VertArgs[1]==0.0) {
printf("Vertical level increment is zero, must be non-zero\n");
invalid = 1;
}
break;
case 2:
/* Check that Height values increase upward */
for (i=1;i<maxnl;i++) {
if (v->VertArgs[i] <= v->VertArgs[i-1]) {
printf("Height[%d]=%f <= Height[%d]=%f, level heights must increase\n",
i, v->VertArgs[i], i-1, v->VertArgs[i-1] );
invalid = 1;
break;
}
}
break;
case 3:
/* Check that Pressure values decrease upward */
for (i=1;i<maxnl;i++) {
if (v->VertArgs[i] <= v->VertArgs[i-1]) {
printf("Pressure[%d]=%f >= Pressure[%d]=%f, level pressures must decrease\n",
i, height_to_pressure(v->VertArgs[i]),
i-1, height_to_pressure(v->VertArgs[i-1]) );
invalid = 1;
break;
}
}
break;
default:
printf("VerticalSystem = %d, must be in 0..3\n", v->VerticalSystem );
invalid = 1;
}
switch (v->Projection) {
case 0: /* Generic */
if (v->ProjArgs[2]==0.0) {
printf("Row Increment (ProjArgs[2]) can't be zero\n");
invalid = 1;
}
if (v->ProjArgs[3]==0.0) {
printf("Column increment (ProjArgs[3]) can't be zero\n");
invalid = 1;
}
break;
case 1: /* Cylindrical equidistant */
if (v->ProjArgs[2]<0.0) {
printf("Row Increment (ProjArgs[2]) = %g (must be >=0.0)\n",
v->ProjArgs[2] );
invalid = 1;
}
if (v->ProjArgs[3]<=0.0) {
printf("Column Increment (ProjArgs[3]) = %g (must be >=0.0)\n",
v->ProjArgs[3] );
invalid = 1;
}
break;
case 2: /* Lambert Conformal */
if (v->ProjArgs[0]<-90.0 || v->ProjArgs[0]>90.0) {
printf("Lat1 (ProjArgs[0]) out of range: %g\n", v->ProjArgs[0] );
invalid = 1;
}
if (v->ProjArgs[1]<-90.0 || v->ProjArgs[1]>90.0) {
printf("Lat2 (ProjArgs[1] out of range: %g\n", v->ProjArgs[1] );
invalid = 1;
}
if (v->ProjArgs[5]<=0.0) {
printf("ColInc (ProjArgs[5]) = %g (must be >=0.0)\n",
v->ProjArgs[5] );
invalid = 1;
}
break;
case 3: /* Stereographic */
if (v->ProjArgs[0]<-90.0 || v->ProjArgs[0]>90.0) {
printf("Central Latitude (ProjArgs[0]) out of range: ");
printf("%g (must be in +/-90)\n", v->ProjArgs[0] );
invalid = 1;
}
if (v->ProjArgs[1]<-180.0 || v->ProjArgs[1]>180.0) {
printf("Central Longitude (ProjArgs[1]) out of range: ");
printf("%g (must be in +/-180)\n", v->ProjArgs[1] );
invalid = 1;
}
if (v->ProjArgs[4]<0) {
printf("Column spacing (ProjArgs[4]) = %g (must be positive)\n",
v->ProjArgs[4]);
invalid = 1;
}
break;
case 4: /* Rotated */
/* WLH 4-21-95 */
if (v->ProjArgs[2]<=0.0) {
printf("Row Increment (ProjArgs[2]) = %g (must be >=0.0)\n",
v->ProjArgs[2] );
invalid = 1;
}
if (v->ProjArgs[3]<=0.0) {
printf("Column Increment = (ProjArgs[3]) %g (must be >=0.0)\n",
v->ProjArgs[3] );
invalid = 1;
}
if (v->ProjArgs[4]<-90.0 || v->ProjArgs[4]>90.0) {
printf("Central Latitude (ProjArgs[4]) out of range: ");
printf("%g (must be in +/-90)\n", v->ProjArgs[4] );
invalid = 1;
}
if (v->ProjArgs[5]<-180.0 || v->ProjArgs[5]>180.0) {
printf("Central Longitude (ProjArgs[5]) out of range: ");
printf("%g (must be in +/-180)\n", v->ProjArgs[5] );
invalid = 1;
}
if (v->ProjArgs[6]<-180.0 || v->ProjArgs[6]>180.0) {
printf("Central Longitude (ProjArgs[6]) out of range: ");
printf("%g (must be in +/-180)\n", v->ProjArgs[6] );
invalid = 1;
}
break;
default:
printf("Projection = %d, must be in 0..4\n", v->Projection );
invalid = 1;
}
return !invalid;
}
/*
* Get the McIDAS file number and grid number associated with the grid
* identified by time and var.
* Input: v - v5d grid struct
* time, var - timestep and variable of grid
* Output: mcfile, mcgrid - McIDAS grid file number and grid number
*/
int v5dGetMcIDASgrid( v5dstruct *v, int time, int var,
int *mcfile, int *mcgrid )
{
if (time<0 || time>=v->NumTimes) {
printf("Bad time argument to v5dGetMcIDASgrid: %d\n", time );
return 0;
}
if (var<0 || var>=v->NumVars) {
printf("Bad var argument to v5dGetMcIDASgrid: %d\n", var );
return 0;
}
*mcfile = (int) v->McFile[time][var];
*mcgrid = (int) v->McGrid[time][var];
return 1;
}
/*
* Set the McIDAS file number and grid number associated with the grid
* identified by time and var.
* Input: v - v5d grid struct
* time, var - timestep and variable of grid
* mcfile, mcgrid - McIDAS grid file number and grid number
* Return: 1 = ok, 0 = error (bad time or var)
*/
int v5dSetMcIDASgrid( v5dstruct *v, int time, int var,
int mcfile, int mcgrid )
{
if (time<0 || time>=v->NumTimes) {
printf("Bad time argument to v5dSetMcIDASgrid: %d\n", time );
return 0;
}
if (var<0 || var>=v->NumVars) {
printf("Bad var argument to v5dSetMcIDASgrid: %d\n", var );
return 0;
}
v->McFile[time][var] = (short) mcfile;
v->McGrid[time][var] = (short) mcgrid;
return 1;
}
/**********************************************************************/
/***** Input Functions *****/
/**********************************************************************/
/*
* Read the header from a COMP* file and return results in the v5dstruct.
* Input: f - the file descriptor
* v - pointer to a v5dstruct.
* Return: 1 = ok, 0 = error.
*/
static int read_comp_header( int f, v5dstruct *v )
{
unsigned int id;
/* reset file position to start of file */
lseek( f, 0, SEEK_SET );
/* read file ID */
read_int4( f, (int *) &id );
if (id==0x80808080 || id==0x80808081) {
/* Older COMP5D format */
int gridtimes, gridparms;
int i, j, it, iv, nl;
int gridsize;
float hgttop, hgtinc;
/*char *compgrid;*/
if (id==0x80808080) {
/* 20 vars, 300 times */
gridtimes = 300;
gridparms = 20;
}
else {
/* 30 vars, 400 times */
gridtimes = 400;
gridparms = 30;
}
v->FirstGridPos = 12*4 + 8*gridtimes + 4*gridparms;
read_int4( f, &v->NumTimes );
read_int4( f, &v->NumVars );
read_int4( f, &v->Nr );
read_int4( f, &v->Nc );
read_int4( f, &nl );
for (i=0;i<v->NumVars;i++) {
v->Nl[i] = nl;
v->LowLev[i] = 0;
}
read_float4( f, &v->ProjArgs[0] );
read_float4( f, &v->ProjArgs[1] );
read_float4( f, &hgttop );
read_float4( f, &v->ProjArgs[2] );
read_float4( f, &v->ProjArgs[3] );
read_float4( f, &hgtinc );
/*
for (i=0;i<nl;i++) {
v->Height[nl-i-1] = hgttop - i * hgtinc;
}
*/
v->VerticalSystem = 1;
v->VertArgs[0] = hgttop - hgtinc * (nl-1);
v->VertArgs[1] = hgtinc;
/* read dates and times */
for (i=0;i<gridtimes;i++) {
read_int4( f, &j );
v->DateStamp[i] = v5dDaysToYYDDD( j );
}
for (i=0;i<gridtimes;i++) {
read_int4( f, &j );
v->TimeStamp[i] = v5dSecondsToHHMMSS( j );
}
/* read variable names */
for (i=0;i<gridparms;i++) {
char name[4];
read_bytes( f, name, 4 );
/* remove trailing spaces, if any */
for (j=3;j>0;j--) {
if (name[j]==' ' || name[j]==0)
name[j] = 0;
else
break;
}
strncpy( v->VarName[i], name, 4 );
v->VarName[i][4] = 0;
}
gridsize = ( (v->Nr * v->Nc * nl + 3) / 4) * 4;
for (i=0;i<v->NumVars;i++) {
v->GridSize[i] = 8 + gridsize;
}
v->SumGridSizes = (8+gridsize) * v->NumVars;
/* read the grids and their ga,gb values to find min and max values */
for (i=0;i<v->NumVars;i++) {
v->MinVal[i] = 999999.9;
v->MaxVal[i] = -999999.9;
}
/*compgrid = (char *) malloc( gridsize );*/
for (it=0; it<v->NumTimes; it++) {
for (iv=0; iv<v->NumVars; iv++) {
float ga, gb;
float min, max;
read_float4( f, &ga );
read_float4( f, &gb );
/* skip ahead by 'gridsize' bytes */
if (lseek( f, gridsize, SEEK_CUR )==-1) {
printf("Error: Unexpected end of file, ");
printf("file may be corrupted.\n");
return 0;
}
min = -(125.0+gb)/ga;
max = (125.0-gb)/ga;
if (min<v->MinVal[iv]) v->MinVal[iv] = min;
if (max>v->MaxVal[iv]) v->MaxVal[iv] = max;
}
}
/*free( compgrid );*/
/* done */
}
else if (id==0x80808082 || id==0x80808083) {
/* Newer COMP5D format */
int gridtimes, gridsize;
int it, iv, nl, i, j;
float delta;
read_int4( f, &gridtimes );
read_int4( f, &v->NumVars );
read_int4( f, &v->NumTimes );
read_int4( f, &v->Nr );
read_int4( f, &v->Nc );
read_int4( f, &nl );
for (i=0;i<v->NumVars;i++) {
v->Nl[i] = nl;
}
read_float4( f, &v->ProjArgs[2] );
read_float4( f, &v->ProjArgs[3] );
/* Read height and determine if equal spacing */
v->VerticalSystem = 1;
for (i=0;i<nl;i++) {
read_float4( f, &v->VertArgs[i] );
if (i==1) {
delta = v->VertArgs[1] - v->VertArgs[0];
}
else if (i>1) {
if (delta != (v->VertArgs[i] - v->VertArgs[i-1])) {
v->VerticalSystem = 2;
}
}
}
if (v->VerticalSystem==1) {
v->VertArgs[1] = delta;
}
/* read variable names */
for (iv=0; iv<v->NumVars; iv++) {
char name[8];
read_bytes( f, name, 8 );
/* remove trailing spaces, if any */
for (j=7;j>0;j--) {
if (name[j]==' ' || name[j]==0)
name[j] = 0;
else
break;
}
strncpy( v->VarName[iv], name, 8 );
v->VarName[iv][8] = 0;
}
for (iv=0;iv<v->NumVars;iv++) {
read_float4( f, &v->MinVal[iv] );
}
for (iv=0;iv<v->NumVars;iv++) {
read_float4( f, &v->MaxVal[iv] );
}
for (it=0;it<gridtimes;it++) {
read_int4( f, &j );
v->TimeStamp[it] = v5dSecondsToHHMMSS( j );
}
for (it=0;it<gridtimes;it++) {
read_int4( f, &j );
v->DateStamp[it] = v5dDaysToYYDDD( j );
}
for (it=0;it<gridtimes;it++) {
float nlat;
read_float4( f, &nlat );
if (it==0) v->ProjArgs[0] = nlat;
}
for (it=0;it<gridtimes;it++) {
float wlon;
read_float4( f, &wlon );
if (it==0) v->ProjArgs[1] = wlon;
}
/* calculate grid storage sizes */
if (id==0x80808082) {
gridsize = nl*2*4 + ( (v->Nr * v->Nc * nl + 3) / 4) * 4;
}
else {
/* McIDAS grid and file numbers present */
gridsize = 8 + nl*2*4 + ( (v->Nr * v->Nc * nl + 3) / 4) * 4;
}
for (i=0;i<v->NumVars;i++) {
v->GridSize[i] = gridsize;
}
v->SumGridSizes = gridsize * v->NumVars;
/* read McIDAS numbers??? */
/* size (in bytes) of all header info */
v->FirstGridPos = 9*4 + v->Nl[0]*4 + v->NumVars*16 + gridtimes*16;
}
v->CompressMode = 1; /* one byte per grid point */
v->Projection = 1; /* Cylindrical equidistant */
v->FileVersion[0] = 0;
return 1;
}
/*
* Read a compressed grid from a COMP* file.
* Return: 1 = ok, 0 = error.
*/
static int read_comp_grid( v5dstruct *v, int time, int var,
float *ga, float *gb, void *compdata )
{
unsigned int pos;
V5Dubyte bias;
int i, n, nl;
int f;
V5Dubyte *compdata1 = (V5Dubyte *) compdata;
f = v->FileDesc;
/* move to position in file */
pos = grid_position( v, time, var );
lseek( f, pos, SEEK_SET );
if (v->FileFormat==0x80808083) {
/* read McIDAS grid and file numbers */
int mcfile, mcgrid;
read_int4( f, &mcfile );
read_int4( f, &mcgrid );
v->McFile[time][var] = (short) mcfile;
v->McGrid[time][var] = (short) mcgrid;
}
nl = v->Nl[var];
if (v->FileFormat==0x80808080 || v->FileFormat==0x80808081) {
/* single ga,gb pair for whole grid */
float a, b;
read_float4( f, &a );
read_float4( f, &b );
/* convert a, b to new v5d ga, gb values */
for (i=0;i<nl;i++) {
if (a==0.0) {
ga[i] = gb[i] = 0.0;
}
else {
gb[i] = (b+128.0) / -a;
ga[i] = 1.0 / a;
}
}
bias = 128;
}
else {
/* read ga, gb arrays */
read_float4_array( f, ga, v->Nl[var] );
read_float4_array( f, gb, v->Nl[var] );
/* convert ga, gb values to v5d system */
for (i=0;i<nl;i++) {
if (ga[i]==0.0) {
ga[i] = gb[i] = 0.0;
}
else {
/*gb[i] = (gb[i]+125.0) / -ga[i];*/
gb[i] = (gb[i]+128.0) / -ga[i];
ga[i] = 1.0 / ga[i];
}
}
bias = 128; /* 125 ??? */
}
/* read compressed grid data */
n = v->Nr * v->Nc * v->Nl[var];
if (read_bytes( f, compdata1, n )!=n)
return 0;
/* convert data values to v5d system */
n = v->Nr * v->Nc * v->Nl[var];
for (i=0;i<n;i++) {
compdata1[i] += bias;
}
return 1;
}
/*
* Read a v5d file header.
* Input: f - file opened for reading.
* v - pointer to v5dstruct to store header info into.
* Return: 1 = ok, 0 = error.
*/
static int read_v5d_header( v5dstruct *v )
{
#define SKIP(N) lseek( f, N, SEEK_CUR )
int end_of_header = 0;
unsigned int id;
int idlen, var, numargs;
int f;
f = v->FileDesc;
/* first try to read the header id */
read_int4( f, (int*) &id );
read_int4( f, &idlen );
if (id==TAG_ID && idlen==0) {
/* this is a v5d file */
v->FileFormat = 0;
}
else if (id>=0x80808080 && id<=0x80808083) {
/* this is an old COMP* file */
v->FileFormat = id;
return read_comp_header( f, v );
}
else {
/* unknown file type */
printf("Error: not a v5d file\n");
return 0;
}
v->CompressMode = 1; /* default */
while (!end_of_header) {
int tag, length;
int i, var, time, nl, lev;
if (read_int4(f,&tag)<1 || read_int4(f,&length)<1) {
printf("Error while reading header, premature EOF\n");
return 0;
}
switch (tag) {
case TAG_VERSION:
assert( length==10 );
read_bytes( f, v->FileVersion, 10 );
/* Check if reading a file made by a future version of Vis5D */
if (strcmp(v->FileVersion, FILE_VERSION)>0) {
/* WLH 6 Oct 98 */
printf("Warning: Trying to read a version %s file,", v->FileVersion);
printf(" you should upgrade Vis5D.\n");
}
break;
case TAG_NUMTIMES:
assert( length==4 );
read_int4( f, &v->NumTimes );
break;
case TAG_NUMVARS:
assert( length==4 );
read_int4( f, &v->NumVars );
break;
case TAG_VARNAME:
assert( length==14 ); /* 1 int + 10 char */
read_int4( f, &var );
read_bytes( f, v->VarName[var], 10 );
break;
case TAG_NR:
/* Number of rows for all variables */
assert( length==4 );
read_int4( f, &v->Nr );
break;
case TAG_NC:
/* Number of columns for all variables */
assert( length==4 );
read_int4( f, &v->Nc );
break;
case TAG_NL:
/* Number of levels for all variables */
assert( length==4 );
read_int4( f, &nl );
for (i=0;i<v->NumVars;i++) {
v->Nl[i] = nl;
}
break;
case TAG_NL_VAR:
/* Number of levels for one variable */
assert( length==8 );
read_int4( f, &var );
read_int4( f, &v->Nl[var] );
break;
case TAG_LOWLEV_VAR:
/* Lowest level for one variable */
assert( length==8 );
read_int4( f, &var );
read_int4( f, &v->LowLev[var] );
break;
case TAG_TIME:
/* Time stamp for 1 timestep */
assert( length==8 );
read_int4( f, &time );
read_int4( f, &v->TimeStamp[time] );
break;
case TAG_DATE:
/* Date stamp for 1 timestep */
assert( length==8 );
read_int4( f, &time );
read_int4( f, &v->DateStamp[time] );
break;
case TAG_MINVAL:
/* Minimum value for a variable */
assert( length==8 );
read_int4( f, &var );
read_float4( f, &v->MinVal[var] );
break;
case TAG_MAXVAL:
/* Maximum value for a variable */
assert( length==8 );
read_int4( f, &var );
read_float4( f, &v->MaxVal[var] );
break;
case TAG_COMPRESS:
/* Compress mode */
assert( length==4 );
read_int4( f, &v->CompressMode );
break;
case TAG_UNITS:
/* physical units */
assert( length==24 );
read_int4( f, &var );
read_bytes( f, v->Units[var], 20 );
break;
/*
* Vertical coordinate system
*/
case TAG_VERTICAL_SYSTEM:
assert( length==4 );
read_int4( f, &v->VerticalSystem );
if (v->VerticalSystem<0 || v->VerticalSystem>3) {
printf("Error: bad vertical coordinate system: %d\n",
v->VerticalSystem );
}
break;
case TAG_VERT_ARGS:
read_int4( f, &numargs );
assert( numargs <= MAXVERTARGS );
read_float4_array( f, v->VertArgs, numargs );
assert( length==numargs*4+4 );
break;
case TAG_HEIGHT:
/* height of a grid level */
assert( length==8 );
read_int4( f, &lev );
read_float4( f, &v->VertArgs[lev] );
break;
case TAG_BOTTOMBOUND:
assert( length==4 );
read_float4( f, &v->VertArgs[0] );
break;
case TAG_LEVINC:
assert( length==4 );
read_float4( f, &v->VertArgs[1] );
break;
/*
* Map projection information
*/
case TAG_PROJECTION:
assert( length==4 );
read_int4( f, &v->Projection );
if (v->Projection<0 || v->Projection>4) { /* WLH 4-21-95 */
printf("Error while reading header, bad projection (%d)\n",
v->Projection );
return 0;
}
break;
case TAG_PROJ_ARGS:
read_int4( f, &numargs );
assert( numargs <= MAXPROJARGS );
read_float4_array( f, v->ProjArgs, numargs );
assert( length==4*numargs+4 );
break;
case TAG_NORTHBOUND:
assert( length==4 );
if (v->Projection==0 || v->Projection==1 || v->Projection==4) {
read_float4( f, &v->ProjArgs[0] );
}
else {
SKIP( 4 );
}
break;
case TAG_WESTBOUND:
assert( length==4 );
if (v->Projection==0 || v->Projection==1 || v->Projection==4) {
read_float4( f, &v->ProjArgs[1] );
}
else {
SKIP( 4 );
}
break;
case TAG_ROWINC:
assert( length==4 );
if (v->Projection==0 || v->Projection==1 || v->Projection==4) {
read_float4( f, &v->ProjArgs[2] );
}
else {
SKIP( 4 );
}
break;
case TAG_COLINC:
assert( length==4 );
if (v->Projection==0 || v->Projection==1 || v->Projection==4) {
read_float4( f, &v->ProjArgs[3] );
}
else if (v->Projection==2) {
read_float4( f, &v->ProjArgs[5] );
}
else if (v->Projection==3) {
read_float4( f, &v->ProjArgs[4] );
}
else {
SKIP( 4 );
}
break;
case TAG_LAT1:
assert( length==4 );
if (v->Projection==2) {
read_float4( f, &v->ProjArgs[0] );
}
else {
SKIP( 4 );
}
break;
case TAG_LAT2:
assert( length==4 );
if (v->Projection==2) {
read_float4( f, &v->ProjArgs[1] );
}
else {
SKIP( 4 );
}
break;
case TAG_POLE_ROW:
assert( length==4 );
if (v->Projection==2) {
read_float4( f, &v->ProjArgs[2] );
}
else {
SKIP( 4 );
}
break;
case TAG_POLE_COL:
assert( length==4 );
if (v->Projection==2) {
read_float4( f, &v->ProjArgs[3] );
}
else {
SKIP( 4 );
}
break;
case TAG_CENTLON:
assert( length==4 );
if (v->Projection==2) {
read_float4( f, &v->ProjArgs[4] );
}
else if (v->Projection==3) {
read_float4( f, &v->ProjArgs[1] );
}
else if (v->Projection==4) { /* WLH 4-21-95 */
read_float4( f, &v->ProjArgs[5] );
}
else {
SKIP( 4 );
}
break;
case TAG_CENTLAT:
assert( length==4 );
if (v->Projection==3) {
read_float4( f, &v->ProjArgs[0] );
}
else if (v->Projection==4) { /* WLH 4-21-95 */
read_float4( f, &v->ProjArgs[4] );
}
else {
SKIP( 4 );
}
break;
case TAG_CENTROW:
assert( length==4 );
if (v->Projection==3) {
read_float4( f, &v->ProjArgs[2] );
}
else {
SKIP( 4 );
}
break;
case TAG_CENTCOL:
assert( length==4 );
if (v->Projection==3) {
read_float4( f, &v->ProjArgs[3] );
}
else {
SKIP( 4 );
}
break;
case TAG_ROTATION:
assert( length==4 );
if (v->Projection==4) { /* WLH 4-21-95 */
read_float4( f, &v->ProjArgs[6] );
}
else {
SKIP( 4 );
}
break;
case TAG_END:
/* end of header */
end_of_header = 1;
lseek( f, length, SEEK_CUR );
break;
default:
/* unknown tag, skip to next tag */
printf("Unknown tag: %d length=%d\n", tag, length );
lseek( f, length, SEEK_CUR );
break;
}
}
v5dVerifyStruct( v );
/* Now we're ready to read the grid data */
/* Save current file pointer */
v->FirstGridPos = ltell(f);
/* compute grid sizes */
v->SumGridSizes = 0;
for (var=0;var<v->NumVars;var++) {
v->GridSize[var] = 8 * v->Nl[var] + v5dSizeofGrid( v, 0, var );
v->SumGridSizes += v->GridSize[var];
}
return 1;
#undef SKIP
}
/*
* Open a v5d file for reading.
* Input: filename - name of v5d file to open
* v - pointer to a v5dstruct in which to put header info or NULL
* if a struct should be dynamically allocated.
* Return: NULL if error, else v or a pointer to a new v5dstruct if v was NULL
*/
v5dstruct *v5dOpenFile( const char *filename, v5dstruct *v )
{
int fd;
fd = open( filename, O_RDONLY );
if (fd==-1) {
/* error */
return 0;
}
if (v) {
v5dInitStruct( v );
}
else {
v = v5dNewStruct();
if (!v) {
return NULL;
}
}
v->FileDesc = fd;
v->Mode = 'r';
if (read_v5d_header( v )) {
return v;
}
else {
return NULL;
}
}
/*
* Read a compressed grid from a v5d file.
* Input: v - pointer to v5dstruct describing the file
* time, var - which timestep and variable
* ga, gb - arrays to store grid (de)compression values
* compdata - address of where to store compressed grid data.
* Return: 1 = ok, 0 = error.
*/
int v5dReadCompressedGrid( v5dstruct *v, int time, int var,
float *ga, float *gb, void *compdata )
{
int pos, n, k;
if (time<0 || time>=v->NumTimes) {
printf("Error in v5dReadCompressedGrid: bad timestep argument (%d)\n",
time);
return 0;
}
if (var<0 || var>=v->NumVars) {
printf("Error in v5dReadCompressedGrid: bad var argument (%d)\n",
var);
return 0;
}
if (v->FileFormat) {
/* old COMP* file */
return read_comp_grid( v, time, var, ga, gb, compdata );
}
/* move to position in file */
pos = grid_position( v, time, var );
lseek( v->FileDesc, pos, SEEK_SET );
/* read ga, gb arrays */
read_float4_array( v->FileDesc, ga, v->Nl[var] );
read_float4_array( v->FileDesc, gb, v->Nl[var] );
/* read compressed grid data */
n = v->Nr * v->Nc * v->Nl[var];
if (v->CompressMode==1) {
k = read_block( v->FileDesc, compdata, n, 1 )==n;
}
else if (v->CompressMode==2) {
k = read_block( v->FileDesc, compdata, n, 2 )==n;
}
else if (v->CompressMode==4) {
k = read_block( v->FileDesc, compdata, n, 4 )==n;
}
if (!k) {
/* error */
printf("Error in v5dReadCompressedGrid: read failed, bad file?\n");
}
return k;
/*
n = v->Nr * v->Nc * v->Nl[var] * v->CompressMode;
if (read( v->FileDesc, compdata, n )==n)
return 1;
else
return 0;
*/
}
/*
* Read a grid from a v5d file, decompress it and return it.
* Input: v - pointer to v5dstruct describing file header
* time, var - which timestep and variable.
* data - address of buffer to put grid data
* Output: data - the grid data
* Return: 1 = ok, 0 = error.
*/
int v5dReadGrid( v5dstruct *v, int time, int var, float data[] )
{
float ga[MAXLEVELS], gb[MAXLEVELS];
void *compdata;
int bytes;
if (time<0 || time>=v->NumTimes) {
printf("Error in v5dReadGrid: bad timestep argument (%d)\n", time);
return 0;
}
if (var<0 || var>=v->NumVars) {
printf("Error in v5dReadGrid: bad variable argument (%d)\n", var);
return 0;
}
/* allocate compdata buffer */
if (v->CompressMode==1) {
bytes = v->Nr * v->Nc * v->Nl[var] * sizeof(unsigned char);
}
else if (v->CompressMode==2) {
bytes = v->Nr * v->Nc * v->Nl[var] * sizeof(unsigned short);
}
else if (v->CompressMode==4) {
bytes = v->Nr * v->Nc * v->Nl[var] * sizeof(float);
}
compdata = (void *) malloc( bytes );
if (!compdata) {
printf("Error in v5dReadGrid: out of memory (needed %d bytes)\n", bytes);
return 0;
}
/* read the compressed data */
if (!v5dReadCompressedGrid( v, time, var, ga, gb, compdata )) {
return 0;
}
/* decompress the data */
v5dDecompressGrid( v->Nr, v->Nc, v->Nl[var], v->CompressMode,
compdata, ga, gb, data );
/* free compdata */
free( compdata );
return 1;
}
/**********************************************************************/
/***** Output Functions *****/
/**********************************************************************/
static int write_tag( v5dstruct *v, int tag, int length, int newfile )
{
if (!newfile) {
/* have to check that there's room in header to write this tagged item */
if (v->CurPos+8+length > v->FirstGridPos) {
printf("Error: out of header space!\n");
/* Out of header space! */
return 0;
}
}
if (write_int4( v->FileDesc, tag )==0) return 0;
if (write_int4( v->FileDesc, length )==0) return 0;
v->CurPos += 8 + length;
return 1;
}
/*
* Write the information in the given v5dstruct as a v5d file header.
* Note that the current file position is restored when this function
* returns normally.
* Input: f - file already open for writing
* v - pointer to v5dstruct
* Return: 1 = ok, 0 = error.
*/
static int write_v5d_header( v5dstruct *v )
{
int var, time, filler, maxnl;
int f;
int newfile;
if (v->FileFormat!=0) {
printf("Error: v5d library can't write comp5d format files.\n");
return 0;
}
f = v->FileDesc;
if (!v5dVerifyStruct( v ))
return 0;
/* Determine if we're writing to a new file */
if (v->FirstGridPos==0) {
newfile = 1;
}
else {
newfile = 0;
}
/* compute grid sizes */
v->SumGridSizes = 0;
for (var=0;var<v->NumVars;var++) {
v->GridSize[var] = 8 * v->Nl[var] + v5dSizeofGrid( v, 0, var );
v->SumGridSizes += v->GridSize[var];
}
/* set file pointer to start of file */
lseek( f, 0, SEEK_SET );
v->CurPos = 0;
/*
* Write the tagged header info
*/
#define WRITE_TAG( V, T, L ) if (!write_tag(V,T,L,newfile)) return 0;
/* ID */
WRITE_TAG( v, TAG_ID, 0 );
/* File Version */
WRITE_TAG( v, TAG_VERSION, 10 );
write_bytes( f, FILE_VERSION, 10 );
/* Number of timesteps */
WRITE_TAG( v, TAG_NUMTIMES, 4 );
write_int4( f, v->NumTimes );
/* Number of variables */
WRITE_TAG( v, TAG_NUMVARS, 4 );
write_int4( f, v->NumVars );
/* Names of variables */
for (var=0;var<v->NumVars;var++) {
WRITE_TAG( v, TAG_VARNAME, 14 );
write_int4( f, var );
write_bytes( f, v->VarName[var], 10 );
}
/* Physical Units */
for (var=0;var<v->NumVars;var++) {
WRITE_TAG( v, TAG_UNITS, 24 );
write_int4( f, var );
write_bytes( f, v->Units[var], 20 );
}
/* Date and time of each timestep */
for (time=0;time<v->NumTimes;time++) {
WRITE_TAG( v, TAG_TIME, 8 );
write_int4( f, time );
write_int4( f, v->TimeStamp[time] );
WRITE_TAG( v, TAG_DATE, 8 );
write_int4( f, time );
write_int4( f, v->DateStamp[time] );
}
/* Number of rows */
WRITE_TAG( v, TAG_NR, 4 );
write_int4( f, v->Nr );
/* Number of columns */
WRITE_TAG( v, TAG_NC, 4 );
write_int4( f, v->Nc );
/* Number of levels, compute maxnl */
maxnl = 0;
for (var=0;var<v->NumVars;var++) {
WRITE_TAG( v, TAG_NL_VAR, 8 );
write_int4( f, var );
write_int4( f, v->Nl[var] );
WRITE_TAG( v, TAG_LOWLEV_VAR, 8 );
write_int4( f, var );
write_int4( f, v->LowLev[var] );
if (v->Nl[var]+v->LowLev[var]>maxnl) {
maxnl = v->Nl[var]+v->LowLev[var];
}
}
/* Min/Max values */
for (var=0;var<v->NumVars;var++) {
WRITE_TAG( v, TAG_MINVAL, 8 );
write_int4( f, var );
write_float4( f, v->MinVal[var] );
WRITE_TAG( v, TAG_MAXVAL, 8 );
write_int4( f, var );
write_float4( f, v->MaxVal[var] );
}
/* Compress mode */
WRITE_TAG( v, TAG_COMPRESS, 4 );
write_int4( f, v->CompressMode );
/* Vertical Coordinate System */
WRITE_TAG( v, TAG_VERTICAL_SYSTEM, 4 );
write_int4( f, v->VerticalSystem );
WRITE_TAG( v, TAG_VERT_ARGS, 4+4*MAXVERTARGS );
write_int4( f, MAXVERTARGS );
write_float4_array( f, v->VertArgs, MAXVERTARGS );
/* Map Projection */
WRITE_TAG( v, TAG_PROJECTION, 4 );
write_int4( f, v->Projection );
WRITE_TAG( v, TAG_PROJ_ARGS, 4+4*MAXPROJARGS );
write_int4( f, MAXPROJARGS );
write_float4_array( f, v->ProjArgs, MAXPROJARGS );
/* write END tag */
if (newfile) {
/* We're writing to a brand new file. Reserve 10000 bytes */
/* for future header growth. */
WRITE_TAG( v, TAG_END, 10000 );
lseek( f, 10000, SEEK_CUR );
/* Let file pointer indicate where first grid is stored */
v->FirstGridPos = ltell( f );
}
else {
/* we're rewriting a header */
filler = v->FirstGridPos - ltell(f);
WRITE_TAG( v, TAG_END, filler-8 );
}
#undef WRITE_TAG
return 1;
}
/*
* Open a v5d file for writing. If the named file already exists,
* it will be deleted.
* Input: filename - name of v5d file to create.
* v - pointer to v5dstruct with the header info to write.
* Return: 1 = ok, 0 = error.
*/
int v5dCreateFile( const char *filename, v5dstruct *v )
{
mode_t mask;
int fd;
mask = 0666;
fd = open( filename, O_WRONLY | O_CREAT | O_TRUNC, mask );
if (fd==-1) {
printf("Error in v5dCreateFile: open failed\n");
v->FileDesc = -1;
v->Mode = 0;
return 0;
}
else {
/* ok */
v->FileDesc = fd;
v->Mode = 'w';
/* write header and return status */
return write_v5d_header(v);
}
}
/*
* Open a v5d file for updating/appending and read the header info.
* Input: filename - name of v5d file to open for updating.
* v - pointer to v5dstruct in which the file header info will be
* put. If v is NULL a v5dstruct will be allocated and returned.
* Return: NULL if error, else v or a pointer to a new v5dstruct if v as NULL
*/
v5dstruct *v5dUpdateFile( const char *filename, v5dstruct *v )
{
int fd;
fd = open( filename, O_RDWR );
if (fd==-1) {
return NULL;
}
if (!v) {
v = v5dNewStruct();
if (!v) {
return NULL;
}
}
v->FileDesc = fd;
v->Mode = 'w';
if (read_v5d_header( v )) {
return v;
}
else {
return NULL;
}
}
/*
* Write a compressed grid to a v5d file.
* Input: v - pointer to v5dstruct describing the file
* time, var - which timestep and variable
* ga, gb - the GA and GB (de)compression value arrays
* compdata - address of array of compressed data values
* Return: 1 = ok, 0 = error.
*/
int v5dWriteCompressedGrid( const v5dstruct *v, int time, int var,
const float *ga, const float *gb,
const void *compdata )
{
int pos, n, k;
/* simple error checks */
if (v->Mode!='w') {
printf("Error in v5dWriteCompressedGrid: file opened for reading,");
printf(" not writing.\n");
return 0;
}
if (time<0 || time>=v->NumTimes) {
printf("Error in v5dWriteCompressedGrid: bad timestep argument (%d)\n",
time);
return 0;
}
if (var<0 || var>=v->NumVars) {
printf("Error in v5dWriteCompressedGrid: bad variable argument (%d)\n",
var);
return 0;
}
/* move to position in file */
pos = grid_position( v, time, var );
if (lseek( v->FileDesc, pos, SEEK_SET )<0) {
/* lseek failed, return error */
printf("Error in v5dWrite[Compressed]Grid: seek failed, disk full?\n");
return 0;
}
/* write ga, gb arrays */
k = 0;
if (write_float4_array( v->FileDesc, ga, v->Nl[var] ) == v->Nl[var] &&
write_float4_array( v->FileDesc, gb, v->Nl[var] ) == v->Nl[var]) {
/* write compressed grid data (k=1=OK, k=0=Error) */
n = v->Nr * v->Nc * v->Nl[var];
if (v->CompressMode==1) {
k = write_block( v->FileDesc, compdata, n, 1 )==n;
}
else if (v->CompressMode==2) {
k = write_block( v->FileDesc, compdata, n, 2 )==n;
}
else if (v->CompressMode==4) {
k = write_block( v->FileDesc, compdata, n, 4 )==n;
}
}
if (k==0) {
/* Error while writing */
printf("Error in v5dWrite[Compressed]Grid: write failed, disk full?\n");
}
return k;
/*
n = v->Nr * v->Nc * v->Nl[var] * v->CompressMode;
if (write_bytes( v->FileDesc, compdata, n )!=n) {
printf("Error in v5dWrite[Compressed]Grid: write failed, disk full?\n");
return 0;
}
else {
return 1;
}
*/
}
/*
* Compress a grid and write it to a v5d file.
* Input: v - pointer to v5dstruct describing the file
* time, var - which timestep and variable (starting at 0)
* data - address of uncompressed grid data
* Return: 1 = ok, 0 = error.
*/
int v5dWriteGrid( v5dstruct *v, int time, int var, const float data[] )
{
float ga[MAXLEVELS], gb[MAXLEVELS];
void *compdata;
int n, bytes;
float min, max;
if (v->Mode!='w') {
printf("Error in v5dWriteGrid: file opened for reading,");
printf(" not writing.\n");
return 0;
}
if (time<0 || time>=v->NumTimes) {
printf("Error in v5dWriteGrid: bad timestep argument (%d)\n", time);
return 0;
}
if (var<0 || var>=v->NumVars) {
printf("Error in v5dWriteGrid: bad variable argument (%d)\n", var);
return 0;
}
/* allocate compdata buffer */
if (v->CompressMode==1) {
bytes = v->Nr * v->Nc * v->Nl[var] * sizeof(unsigned char);
}
else if (v->CompressMode==2) {
bytes = v->Nr * v->Nc * v->Nl[var] * sizeof(unsigned short);
}
else if (v->CompressMode==4) {
bytes = v->Nr * v->Nc * v->Nl[var] * sizeof(float);
}
compdata = (void *) malloc( bytes );
if (!compdata) {
printf("Error in v5dWriteGrid: out of memory (needed %d bytes)\n",
bytes );
return 0;
}
/* compress the grid data */
v5dCompressGrid( v->Nr, v->Nc, v->Nl[var], v->CompressMode, data,
compdata, ga, gb, &min, &max );
/* update min and max value */
if (min<v->MinVal[var])
v->MinVal[var] = min;
if (max>v->MaxVal[var])
v->MaxVal[var] = max;
/* write the compressed grid */
n = v5dWriteCompressedGrid( v, time, var, ga, gb, compdata );
/* free compdata */
free( compdata );
return n;
}
/*
* Close a v5d file which was opened with open_v5d_file() or
* create_v5d_file().
* Input: f - file descriptor
* Return: 1 = ok, 0 = error
*/
int v5dCloseFile( v5dstruct *v )
{
int status = 1;
if (v->Mode=='w') {
/* rewrite header because writing grids updates the minval and */
/* maxval fields */
lseek( v->FileDesc, 0, SEEK_SET );
status = write_v5d_header( v );
lseek( v->FileDesc, 0, SEEK_END );
close( v->FileDesc );
}
else if (v->Mode=='r') {
/* just close the file */
close(v->FileDesc);
}
else {
printf("Error in v5dCloseFile: bad v5dstruct argument\n");
return 0;
}
v->FileDesc = -1;
v->Mode = 0;
return status;
}
/**********************************************************************/
/***** Simple v5d file writing functions. *****/
/**********************************************************************/
static v5dstruct *Simple = NULL;
/*
* Create a new v5d file specifying both a map projection and vertical
* coordinate system. See README file for argument details.
* Return: 1 = ok, 0 = error.
*/
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[] )
{
int var, time, maxnl, i;
/* initialize the v5dstruct */
Simple = v5dNewStruct();
Simple->NumTimes = numtimes;
Simple->NumVars = numvars;
Simple->Nr = nr;
Simple->Nc = nc;
maxnl = nl[0];
for (var=0;var<numvars;var++) {
if (nl[var]>maxnl) {
maxnl = nl[var];
}
Simple->Nl[var] = nl[var];
Simple->LowLev[var] = 0;
strncpy( Simple->VarName[var], varname[var], 10 );
Simple->VarName[var][9] = 0;
}
/* time and date for each timestep */
for (time=0;time<numtimes;time++) {
Simple->TimeStamp[time] = timestamp[time];
Simple->DateStamp[time] = datestamp[time];
}
Simple->CompressMode = compressmode;
/* Map projection and vertical coordinate system */
Simple->Projection = projection;
#ifdef VPP
{
int i;
for (i=0;i<MAXPROJARGS;i++)
Simple->ProjArgs[i] = (float)proj_args[i];
}
#else
memcpy( Simple->ProjArgs, proj_args, MAXPROJARGS*sizeof(float) );
#endif
Simple->VerticalSystem = vertical;
if (vertical == 3) {
/* convert pressures to heights */
for (i=0; i<MAXVERTARGS; i++) {
if (vert_args[i] > 0.000001) {
Simple->VertArgs[i] = pressure_to_height((float)vert_args[i]);
}
else Simple->VertArgs[i] = 0.0;
}
}
else {
#ifdef VPP
{
int i;
for (i=0;i<MAXVERTARGS;i++)
Simple->VertArgs[i] = (float)vert_args[i];
}
#else
memcpy( Simple->VertArgs, vert_args, MAXVERTARGS*sizeof(float) );
#endif
}
/* create the file */
if (v5dCreateFile( name, Simple )==0) {
printf("Error in v5dCreateSimpleFile: unable to create %s\n", name );
return 0;
}
else {
return 1;
}
}
/*
* Create a new v5d file using minimal information.
* Return: 1 = ok, 0 = error. See README file for argument details.
*/
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 )
{
int nlvar[MAXVARS];
int compressmode, projection, vertical;
FLOAT proj_args[100], vert_args[MAXLEVELS];
int i;
for (i=0;i<numvars;i++) {
nlvar[i] = nl;
}
compressmode = 1;
projection = 1;
proj_args[0] = northlat;
proj_args[1] = westlon;
proj_args[2] = latinc;
proj_args[3] = loninc;
vertical = 1;
vert_args[0] = bottomhgt;
vert_args[1] = hgtinc;
return v5dCreate( name, numtimes, numvars, nr, nc, nlvar,
varname, timestamp, datestamp, compressmode,
projection, proj_args, vertical, vert_args );
}
/*
* Set lowest levels for each variable (other than default of 0).
* Input: lowlev - array [NumVars] of ints
* Return: 1 = ok, 0 = error
*/
int v5dSetLowLev( int lowlev[] )
{
int var;
if (Simple) {
for (var=0;var<Simple->NumVars;var++) {
Simple->LowLev[var] = lowlev[var];
}
return 1;
}
else {
printf("Error: must call v5dCreate before v5dSetLowLev\n");
return 0;
}
}
/*
* Set the units for a variable.
* Input: var - a variable in [1,NumVars]
* units - a string
* Return: 1 = ok, 0 = error
*/
int v5dSetUnits( int var, const char *units )
{
if (Simple) {
if (var>=1 && var<=Simple->NumVars) {
strncpy( Simple->Units[var-1], units, 19 );
Simple->Units[var-1][19] = 0;
return 1;
}
else {
printf("Error: bad variable number in v5dSetUnits\n");
return 0;
}
}
else {
printf("Error: must call v5dCreate before v5dSetUnits\n");
return 0;
}
}
/*
* Write a grid to a v5d file.
* Input: time - timestep in [1,NumTimes]
* var - timestep in [1,NumVars]
* data - array [nr*nc*nl] of floats
* Return: 1 = ok, 0 = error
*/
int v5dWrite( int time, int var, const FLOAT data[] )
{
if (Simple) {
if (time<1 || time>Simple->NumTimes) {
printf("Error in v5dWrite: bad timestep number: %d\n", time );
return 0;
}
if (var<1 || var>Simple->NumVars) {
printf("Error in v5dWrite: bad variable number: %d\n", var );
}
#ifdef VPP
{
float *rdata;
int i,irep;
int size = Simple->Nr * Simple->Nc * Simple->Nl[var-1];
rdata = (float *)malloc(size * 4);
if (!rdata){
printf("Error in v5dWrite: out of memory\n");
return 0;
}
for (i=0;i<size;i++)
rdata[i] = (float)data[i];
irep = v5dWriteGrid( Simple, time-1, var-1, rdata );
free(rdata);
return irep;
}
#else
return v5dWriteGrid( Simple, time-1, var-1, data );
#endif
}
else {
printf("Error: must call v5dCreate before v5dWrite\n");
return 0;
}
}
/*
* Close a v5d file after the last grid has been written to it.
* Return: 1 = ok, 0 = error
*/
int v5dClose( void )
{
if (Simple) {
int ok = v5dCloseFile( Simple );
v5dFreeStruct( Simple );
return ok;
}
else {
printf("Error: v5dClose: no file to close\n");
return 0;
}
}
/**********************************************************************/
/***** FORTRAN-callable simple output *****/
/**********************************************************************/
/*
* Create a v5d file. See README file for argument descriptions.
* Return: 1 = ok, 0 = error.
*/
#ifdef UNDERSCORE
int v5dcreate_
#else
# ifdef _CRAY
int V5DCREATE
# else
int v5dcreate
# endif
#endif
( const char *name, const int *numtimes, const int *numvars,
const int *nr, const int *nc, const int nl[],
const char varname[][10],
const int timestamp[], const int datestamp[],
const int *compressmode,
const int *projection,
const FLOAT proj_args[],
const int *vertical,
const FLOAT vert_args[] )
{
char filename[100];
char names[MAXVARS][10];
int i, maxnl, args;
/* copy name to filename and remove trailing spaces if any */
copy_string( filename, name, 100 );
/*
* Check for uninitialized arguments
*/
if (*numtimes<1) {
printf("Error: numtimes invalid\n");
return 0;
}
if (*numvars<1) {
printf("Error: numvars invalid\n");
return 0;
}
if (*nr<2) {
printf("Error: nr invalid\n");
return 0;
}
if (*nc<2) {
printf("Error: nc invalid\n");
return 0;
}
maxnl = 0;
for (i=0;i<*numvars;i++) {
if (nl[i]<1) {
printf("Error: nl(%d) invalid\n", i+1);
return 0;
}
if (nl[i]>maxnl) {
maxnl = nl[i];
}
}
for (i=0;i<*numvars;i++) {
if (copy_string2( names[i], varname[i], 10)==0) {
printf("Error: unitialized varname(%d)\n", i+1);
return 0;
}
}
for (i=0;i<*numtimes;i++) {
if (timestamp[i]<0) {
printf("Error: times(%d) invalid\n", i+1);
return 0;
}
if (datestamp[i]<0) {
printf("Error: dates(%d) invalid\n", i+1);
return 0;
}
}
if (*compressmode != 1 && *compressmode != 2 && *compressmode != 4) {
printf("Error: compressmode invalid\n");
return 0;
}
switch (*projection) {
case 0:
args = 4;
break;
case 1:
args = 0;
if (IS_MISSING(proj_args[0])) {
printf("Error: northlat (proj_args(1)) invalid\n");
return 0;
}
if (IS_MISSING(proj_args[1])) {
printf("Error: westlon (proj_args(2)) invalid\n");
return 0;
}
if (IS_MISSING(proj_args[2])) {
printf("Error: latinc (proj_args(3)) invalid\n");
return 0;
}
if (IS_MISSING(proj_args[3])) {
printf("Error: loninc (proj_args(4)) invalid\n");
return 0;
}
break;
case 2:
args = 6;
break;
case 3:
args = 5;
break;
case 4:
args = 7;
break;
default:
args = 0;
printf("Error: projection invalid\n");
return 0;
}
for (i=0;i<args;i++) {
if (IS_MISSING(proj_args[i])) {
printf("Error: proj_args(%d) invalid\n", i+1);
return 0;
}
}
switch (*vertical) {
case 0:
/* WLH 31 Oct 96 - just fall through
args = 4;
break;
*/
case 1:
args = 0;
if (IS_MISSING(vert_args[0])) {
printf("Error: bottomhgt (vert_args(1)) invalid\n");
return 0;
}
if (IS_MISSING(vert_args[1])) {
printf("Error: hgtinc (vert_args(2)) invalid\n");
return 0;
}
break;
case 2:
case 3:
args = maxnl;
break;
default:
args = 0;
printf("Error: vertical invalid\n");
return 0;
}
for (i=0;i<args;i++) {
if (IS_MISSING(vert_args[i])) {
printf("Error: vert_args(%d) invalid\n", i+1);
return 0;
}
}
return v5dCreate( filename, *numtimes, *numvars, *nr, *nc, nl,
(const char(*)[10]) names, timestamp, datestamp,
*compressmode,
*projection, proj_args, *vertical, vert_args );
}
/*
* Create a simple v5d file. See README file for argument descriptions.
* Return: 1 = ok, 0 = error.
*/
#ifdef UNDERSCORE
int v5dcreatesimple_
#else
# ifdef _CRAY
int V5DCREATESIMPLE
# else
int v5dcreatesimple
# endif
#endif
( const char *name, const int *numtimes, const int *numvars,
const int *nr, const int *nc, const int *nl,
const char varname[][10],
const int timestamp[], const int datestamp[],
const float *northlat, const float *latinc,
const float *westlon, const float *loninc,
const float *bottomhgt, const float *hgtinc )
{
int compressmode, projection, vertical;
FLOAT projarg[100], vertarg[MAXLEVELS];
int varnl[MAXVARS];
int i;
for (i=0;i<MAXVARS;i++) {
varnl[i] = *nl;
}
compressmode = 1;
projection = 1;
projarg[0] = *northlat;
projarg[1] = *westlon;
projarg[2] = *latinc;
projarg[3] = *loninc;
vertical = 1;
vertarg[0] = *bottomhgt;
vertarg[1] = *hgtinc;
#ifdef UNDERSCORE
return v5dcreate_
#else
# ifdef _CRAY
return V5DCREATE
# else
return v5dcreate
# endif
#endif
( name, numtimes, numvars, nr, nc, varnl,
varname, timestamp, datestamp, &compressmode,
&projection, projarg, &vertical, vertarg );
}
/*
* Set lowest levels for each variable (other than default of 0).
* Input: lowlev - array [NumVars] of ints
* Return: 1 = ok, 0 = error
*/
#ifdef UNDERSCORE
int v5dsetlowlev_
#else
# ifdef _CRAY
int V5DSETLOWLEV
# else
int v5dsetlowlev
# endif
#endif
( int *lowlev )
{
return v5dSetLowLev(lowlev);
}
/*
* Set the units for a variable.
* Input: var - variable number in [1,NumVars]
* units - a character string
* Return: 1 = ok, 0 = error
*/
#ifdef UNDERSCORE
int v5dsetunits_
#else
# ifdef _CRAY
int V5DSETUNITS
# else
int v5dsetunits
# endif
#endif
( int *var, char *name )
{
return v5dSetUnits( *var, name );
}
/*
* Write a grid of data to the file.
* Input: time - timestep in [1,NumTimes]
* var - timestep in [1,NumVars]
* data - array [nr*nc*nl] of floats
* Return: 1 = ok, 0 = error
*/
#ifdef UNDERSCORE
int v5dwrite_
#else
# ifdef _CRAY
int V5DWRITE
# else
int v5dwrite
# endif
#endif
( const int *time, const int *var, const FLOAT *data )
{
return v5dWrite( *time, *var, data );
}
/*
* Specify the McIDAS GR3D file number and grid number which correspond
* to the grid specified by time and var.
* Input: time, var - timestep and variable of grid (starting at 1)
* mcfile, mcgrid - McIDAS grid file number and grid number
* Return: 1 = ok, 0 = errror (bad time or var)
*/
#ifdef UNDERSCORE
int v5dmcfile_
#else
# ifdef _CRAY
int V5DMCFILE
# else
int v5dmcfile
# endif
#endif
( const int *time, const int *var,
const int *mcfile, const int *mcgrid )
{
if (*time<1 || *time>Simple->NumTimes) {
printf("Bad time argument to v5dSetMcIDASgrid: %d\n", *time );
return 0;
}
if (*var<1 || *var>Simple->NumVars) {
printf("Bad var argument to v5dSetMcIDASgrid: %d\n", *var );
return 0;
}
Simple->McFile[*time-1][*var-1] = (short) *mcfile;
Simple->McGrid[*time-1][*var-1] = (short) *mcgrid;
return 1;
}
/*
* Close a simple v5d file.
*/
#ifdef UNDERSCORE
int v5dclose_( void )
#else
# ifdef _CRAY
int V5DCLOSE( void )
# else
int v5dclose( void )
# endif
#endif
{
return v5dClose();
}
/* 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
\section{Dealing with diachronic files}
The Meso-NH program of post-processing ({\sc diag}) treats synchronous
files from initialization or simulation.
For a given need, one wants to work on fields stored in
a diachronic file before exploration with {\tt diaprog} or with another
graphical tool to possibly compare with observations.
\begin{itemize}
\item The \texttt{extractdia} tool allows to extract fields from a diachronic
file, on the whole domain or on a part of it, to interpole them (horizontal
grid and/or vertical grid) and to write
them in some other given formats (section \ref{extractdia}).
This program is based on a routine of reading and a routine of writing of
diachronic variables:
they are the essential source lines to deal with a diachronic file.
These 2 routines can be used in the user own program to match his personal
needs. An example of such a program \texttt{exrwdia.f90} and how to compile it
is given in section \ref{exrwdia}.
\end{itemize}
Some other tools based on the 2 routines of reading and writing
are also available to allow easier comparisons with observation
data (sections \ref{mnh2obs} and \ref{obs2mnh}):
\begin{itemize}
\item \texttt{mesonh2obs} to get MesoNH field values at given
observation points (the format of output file is ASCII),
\item \texttt{obs2mesonh} to put observation values on a
given MesoNH grid (the output file has diachronic FM format),
observations can then be plotted with \texttt{diaprog} tool.
\item \texttt{compute\_r00\_pc} to catenate evolution of Lagrangian tracers
back to the model start (as done in {\sc diag} program, see documentation
``Lagrangian trajectory and air-mass tracking analyses with
MesoNH by means of Eulerian passive tracers'', Gheusi and Stein, 2005).
\end{itemize}
The figure \ref{outils_dia} resumes the input and output of these tools.
\begin{figure}[htb]
\centerline{\psfig{file=outils_dia.eps,width=10cm,angle=270} }
\caption{\label{outils_dia}}
\end{figure}
\\
\underline{Remark}:
for all the following tools, the input diachronic files can be located
in another directory than the one in which the tool is invoked (as
for \texttt{diaprog}). In this case, initialise the following shell variable
\begin{verbatim}
export DIRLFI=directory_files_diachro
\end{verbatim}
Shell links will be automatically performed during the execution and
will be removed by the mesonh-shell-tool \texttt{rmlink} at the execution end.
\subsection{Extracte fields, domain, change format with
{\tt extractdia} tool}\label{extractdia}
The input file is a FM diachronic file, either a `true' diachronic one
(its name is ended by {\bf .000} and it contains time series of informations
obtained during the run of the model),
or a `pseudo'-diachronic one (it is the result of the conversion of a
synchronous file, see section \ref{diachro_file}), compressed (with {\tt lfiz})
or not.
The format of the output file is chosen by the user among one of the following:
\begin{itemize}
\item a FM {\sc diac}hronic file,
\item an ASCII file with
{\sc l}atitude-{\sc l}ongitude-{\sc h}eight-{\sc v}alue or
latitude-longitude-height-value,
\item ASCII files with {\sc free} format defined by the user (one file per field),
\item a {\sc cdl} file (converted to NetCDF format at the end of the program,
with \texttt{ncgen} utility of NetCDF package inside the mesonh-shell-tool \texttt{tonetcdf}),
\item a {\sc grib} file (in the future),
\item a {\sc Vis5D} file (in the future).
\end{itemize}
The main program is an interactive one:
the name of input diachronic file, the output format,
the coordinates of the part of the domain,
the name of fields to be read and written are required.
All that is typed on keyboard is saved in {\tt dirextr.}fmt
file, it can be appended and used as input (after renaming it) for the next call
of the tool \\
(e.g. {\tt mv dirextr.DIAC dirDIAC1 ; extractdia < dirDIAC1}).
\\
\\
The advantages for each output format are the following:
\begin{itemize}
\item the wind direction (dd) and wind intensity (ff) could be asked.
\item fields are eventually interpolated according output format,
first vertically and then horizontally.
For vertical interpolation, the user specifies the type of levels (Z or P),
the number of levels and their values (in m or in hPa). No vertical interpolation if the type of levels is K (model levels).
For horizontal interpolation on regular grid in longitude and latitude, the program chooses the optimum values computed for the model grid.
If interpolations are required, the wind components are transformed in zonal and meridian components.
These interpolations do not allow interpolation in a required cross-section, the {\sc ficval} file obtained during a {\tt diaprog} session gives this interpolation.
\item for the {\sc diac}hronic format, the output file will be reduced in size
since it contains only some fields on a part of the domain without any interpolations .
It can still be plotted with {\tt diaprog}.
\item for the {\sc ll*v}/ll*v format, the fields can be interpolated onto a
regular grid in longitude and latitude ({\sc lalo} option) or can remained on
the conformal model grid.
({\sc llzv}/llzv option for interpolation on constant altitude levels,
{\sc llpv}/llpv option for interpolation on constant pression levels
{\sc llhv}/lhzv option to stay on MesoNH vertical levels).
Three header lines give zoom, unit, variable name and temporal informations and
are followed by four values on each line.
\item for the {\sc cdl} format, the fields can be horizontally interpolated
onto a regular grid in longitude and latitude ({\sc lalo} option),
and eventually vertically on some prescribed levels
({\sc zcdl} option for interpolation on constant altitude levels,
{\sc pcdl} option for interpolation on constant pression levels,
{\sc kcdl} option to stay on MesoNH vertical levels).
The CDL format is transformed to binary Netdcf format at the end of the program run by the mesonh-shell-tool \texttt{tonetcdf}.
\item the {\sc free} format allows to get the interpolated values (vertical or horizontal interpolations) without any geographical locations: just values list are available after one header line.
\ignore{
\item for the {\sc grib} format, the fields can be horizontally interpolated
onto a regular grid in longitude and latitude and are vertically interpolated
on constant Z-levels or P-levels.
}%ignore
\end{itemize}
\subsection{Personal modifications: \texttt{exrwdia} program}\label{exrwdia}
The \texttt{extractdia} program uses 2 routines of reading
(\texttt{readvar.f90}) and writing (\texttt{writevar.f90}) of MesoNH variables
as they are stored in diachronic files (that is in 6-dimensional arrays).
These 2 routines can be used in your own program:
an example of such a program is \texttt{exrwdia.f90}.
The source code contains extended comments,
and there are some examples of computation with the extracted fields
(module and direction of components of wind, interpolation on some Z levels,
maximum of a 3D field along the vertical direction, vertical average between two
Z levels).
The use of this method need to be familiar with the Mesonh specificities:
seven grids (Gal-Chen) for the storage of the variables, the U,V wind components are
referenced in the Mesonh grid and are different from the Uzonal and Vmeridian
components.
\subsubsection{Routines of reading and writing}
A diachronic file contain time series of informations that are
self-documented (section \ref{diachro_file}).
The self-documentation is provided by the header of the file, which contains
a list of pre-defined records, and each field (or information)
is stored by several records, the number of them varies
from 8 to 11, according to the type of the information
({\sc cart, mask, spxy, ssol, drst, rspl} or {\sc rapl}).
The subroutine \texttt{readvar.f90} reads the required field. At the first call,
the file is opened, its header is read
(the dimensions of the total domain ({\sc imax, jmax, kmax}),
the orography...)
and some characteristics are computed
(the conformal coordinates, the map factor...).
The required field is then read and available in a 6-dimensional array:
{\sc xvar}(i,j,k,t,n,p)\footnote{For a whole description of 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''.}.
The subroutine \texttt{writevar.f90} writes the field if the wanted output
format is {\sc dia}chronic one.
If it is the first call the header is written, then
the field is stored by the same number of records than when it was read.
The personal code can be inserted in the main program between the call of the
two previous subroutines. For the {\sc free} format, the writing code lines
are to be written in the main program.
\subsubsection{Compilation}
You have to
\begin{itemize}
\item create a sub-directory {\tt src} to put your own source files
\item copy {\tt\$MESONH/MAKE/tools/diachro/src/EXTRACTDIA/exrwdia.f90} to {\tt src/my\_prog.f90} and modify it
\item initialize the shell variable {\tt ARCH} which refers to your system and the compiler used (see
examples as the suffix of files in {\tt \$MESONH/MAKE/conf} directory).
\item compile with \\
{\tt gmaketools PROG=my\_prog OBJS="my\_routine1.o my\_routine2.o" } \\
(the \$MESONH/MAKE/tools/diachro/{\tt Makefile.exrwdia} version will be used).
\end{itemize}
\noindent To update the routines dependances directly inside the Makefile:
\begin{itemize}
\item initialize the following shell variables:
\begin{itemize}
\item {\tt MNH\_LIBTOOLS} which is the directory where the reference sources
for the libraries and tools are,
\item {\tt ARCH} which refers to your system and the compiler used (see
examples as the suffix of files in {\tt \$MNH\_LIBTOOLS/conf} directory).
\end{itemize}
\item copy the {\tt \$MNH\_LIBTOOLS/tools/diachro/Makefile.exrwdia} file in your working directory,
rename it to \texttt{Makefile},
\item compile with {\tt gmake}
\end{itemize}
\subsection{Compare to observations with
{\tt mesonh2obs} tool \label{mnh2obs}}
\subsubsection{Input and output}
The \texttt{mesonh2obs} tool allows to interpolate MesoNH fields
at given points (such as points where observation data are available).
The input files are an ASCII file indicated the position of the points by their
latitude and longitude coordinates as well as vertical dimension if a vertical profile is required, and one or several diachronic FM file(s) with fields to interpolate
at previous points.
Each output file, one for each input FM file, is an ASCII one with six possible
options for lines format
(\textsc{llhv}, llhv, \textsc{llzv}, llzv, \textsc{llpv}, llpv).
In the input ASCII file, each line indicates the location of one point,
all lines have the same format, one of the following :\\
\begin{tabular}{l|ll}
lon lat & and altitudes will be asked by the {\tt mesonh2obs} program\\
lat lon & and altitudes will be asked by the {\tt mesonh2obs} program\\
lon lat altitude(m) & \\
lat lon altitude(m) & \\
\end{tabular} \\
The output ASCII file contains lines with the same format, one of the
following according to the option: \\
\begin{tabular}{l|ll}
lon lat model\_level\_altitude(m)& option \textsc{llhv} \\
lat lon model\_level\_altitude(m)& option llhv \\
lon lat altitude(m) & option \textsc{llzv}&
--interpolation routine \texttt{zinter.f90} for 3D fields\\
lat lon altitude(m) & option llzv& \hspace*{1cm} " \\
lon lat pression(hPa) & option \textsc{llpv} &
--interpolation routine \texttt{pinter.f90} for 3D fields\\
lat lon pression(hPa) & option llpv& \hspace*{1cm} " (pressure variable is read in input FM file) \\
\end{tabular} \\
\subsubsection{Usage}
The tool is an interactive one: the option for the lines format of the output
file, the name of the ASCII file with the location of
the observation points are first asked.
Then the name of the input diachronic files is asked in a loop, and the
name of the fields to interpolate in a second loop:
\begin{verbatim}
mesonh2obs << eof
format_output_file # line format of output file (LLHV/llhv/LLZV/llzv/LLPV/llpv)
format_input_file # LL (lon,lat)ou ll (lat,lon)
altitude_in_input_file # O (altitude_in_m on the third colon)/N
if N, number_vertical_levels # number of vertical levels above
# each lat,lon points
list_of_these_levels # exemple: (in metres or hPa): 500 1500
obs_file # name of the Obs file
0 # control prints (0/1/2/3)
diachronic_file1 # file with fields to be interpolated (without .lfi)
field1_of_diachronic_file1 # field to be interpolated
field2_of_diachronic_file1
END # end of extraction in diachronic_file1
diachronic_file2 # file with fields to be interpolated (without .lfi)
fieldi_of_diachronic_file2 # field to be interpolated
fieldj_of_diachronic_file2
END # end of extraction in diachronic_file2
END # end of diachronic files list
eof
\end{verbatim}
If \texttt{field\_of\_diachronic\_file} contains 'AC' string
(for ACcumulated precipitation), you can substract values of the same field
from a previous diachronic file. Then after line
\texttt{field('AC')\_of\_diachronic\_file}, answer the question:
\begin{verbatim}
"- ACcumulated rain, do you want to make difference with a previous instant
(o\/O\/y\/Y\/n\/N) ?"
\end{verbatim}
if \texttt{Y$/$O}, indicate the name of \texttt{diachronic\_file\_previous}
(without .lfi) in a second supplementary line.
\subsubsection{Method}
The main program retrieves first the $X$ and $Y$ conformal coordinates of each
observation point, then for each read field interpolates it vertically
if required (vertical profile field with option \textsc{llzv}, llzv, \textsc{llpv} or llpv, \textsc{llhv}, llhv),
and finally interpolates horizontally the field and the array of the vertical
profile.
\subsection{Compare to observations with
\texttt{obs2mesonh} tool \label{obs2mnh}}
\subsubsection{Input and output}
The \texttt{obs2mesonh} tool allows to replace observations on a MesoNH grid.
The output file has diachronic FM format: it can be used as input for
\texttt{diaprog} to plot observations in the same background as MesoNH fields.
The input files are one or several ASCII file(s), each of it contains the
values of one type of observation (one value per line, all lines have the same
format: (date-)lon-lat-(alt\_in\_meters-)value or
(date-)lat-lon-(alt\_in\_meters-)value),
and a diachronic FM file which spatial grid will be
used to replace previous observation values.
The output file is a diachronic file with the orography and the grids of the
input diachronic one, each field corresponds to each input observation file.
One or two fields are added for each observation field treated: N\_field\_name
for the number of observation averaged in each grid points and if 2D type, ALT\_field\_name for the altitudes of the observation.
\subsubsection{Usage}
The tool is an interactive one:
\begin{verbatim}
obs2mesonh << eof
file_diachronic_with_zs # initialize MesoNH spatial and temporal grids
0/1/2/3 # verbosity level
LL # format of obs file (LL=lon lat alt value,
# ll=lat lon alt value)
file1_obs # name of obs file (undefined value=999.0)
name_new_field1 # name of the obs field in output file
unit_new_field1 # free characters string for unit
1D/2D/3D # profil of the obs field
# for the 2D case, only K=1 will be initialised
LL # format of obs file (LL=lon lat alt value,
# ll=lat lon alt value)
file2_obs
name_new_field2
unit_new_field2
1D/2D/3D
END # closing of output diachronic file
eof
\end{verbatim}
\subsubsection{Method}
For each observation read in an input file: \\
- the MesoNH grid point I,J containing this observation is searching, \\
- then for observation with 3D profil, the vertical level K is searched
(the MesoNH vertical grid (Gal-Chen) at I,J is taken into account);
for observation with 2D or 1D profil, the first level K=1 is attributed,\\
- the value of the observation is stored on grid point (I,J,K). \\
If several values are stored at the same grid point, arithmetic average of
values is done (when unit is $dBz$, the average is computed in $Ze$).
If there is no values at a grid point, undefined value is put.
The observations whose altitude is below the altitude of the first MesoNH level are stored at level K=1, a warning message is printed in this case.
The wind components are considered zonal and meridian in the observation and
are transformed to wind components in the Mesonh grid.
\subsubsection{Plotting with \texttt{diaprog}}
For plotting observation values with \texttt{diaprog}, you have to use the
pixel mode
\texttt{LSPOT=T}: this option is recommended for sparse data since there is
no interpolation of values for graphic plotting.
For superpose with simulated field, do not forget to fix the extrema
and interval of plotting for the 2 fields in order to compare them.
Here is an example of directives for \texttt{diaprog} to plot observed values
and superpose them with simulated fields:
\begin{verbatim}
LINVWB=T
!
LCOLAREA=T LISO=F
LSPOT=T ! no interpolation
_file1_'file_obs'
T2M
y ! yes to draw a black line around obs pixel
0 0
!
_file2_'file_sim'
NIMNMX=1 XDIAINT_T2M=2. XISOMIN_T2M=-8. XISOMAX_T2M=24.
T2M_ON_ ! for superpose
n ! no black border
T2M_file1_
y ! yes to draw a black line around obs pixel
0 0
quit
\end{verbatim}
\subsection{Catenation of Lagrangian trajectory with
\texttt{compute\_r00\_pc} tool}
\subsubsection{Input and output}
The \texttt{compute\_r00\_pc} tool allows to compute advanced
diagnostics.
related to Lagrangian tracers activated during the model simulation
(\texttt{LLG=.TRUE.} in namelist \texttt{NAM\_CONF}): it is based on the subroutine \texttt{compute\_r00} used in the DIAG program.
See section 2.2 of documentation
``Lagrangian trajectory and air-mass tracking analyses with
MesoNH by means of Eulerian passive tracers'' (Gheusi and Stein, 2005).
The input files are one or several diachronic FM file(s) containing Lagrangian
tracers (\texttt{LGXM,LGYM,LGZM}) simply converted by \texttt{conv2dia} after
simulation, or after {\sc diag} (in the latter case, only Lagrangian
basic diagnostics were asked: \texttt{LTRAJ=.TRUE.}
in namelist \texttt{NAM\_DIAG} with the namelist
\texttt{NAM\_STO\_FILE} empty, and additional diagnostic fields can be asked:
\texttt{CISO='EV'} and \texttt{LMOIST\_E=.T.}
for the example of \ref{sss:compute.nam}),
and an ASCII file named \texttt{compute\_r00.nam} with namelist format.
The output file is a diachronic file containing advanced diagnostics: initial
coordinates resulting from catenation process, initial values of basic
diagnostic fields (present in the input diachronic files) that the Lagrangian
parcels had at initial time(s).
\subsubsection{Usage} \label{sss:compute.nam}
The ASCII file \texttt{compute\_r00.nam} looks as the following:
\begin{verbatim}
&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',
NSTART_SUPP(1)=3 /
&NAM_FIELD CFIELD_LAG(1)='THETAE',
CFIELD_LAG(2)='POVOM' /
\end{verbatim}
The namelist \texttt{NAM\_STO\_FILE} is the same as in the file
\texttt{DIAG1.nam}. The namelist \texttt{NAM\_FIELD} indicates the other
quantities for which initial values have to be computed.
\\
Then to run the tool,
\begin{verbatim}
# initialise the following shell variable (optional if input file
# is in the current directory):
export DIRLFI=directory_files_diachro
# initialise the variable ARCH (LXNAGf95 for PC, HPf90 for HP)
export ARCH=LXNAGf95
# execute
$MESONH/MAKE/tools/diachro/$ARCH/compute_r00_pc
\end{verbatim}
\subsubsection{Method}
The structure of the program and the interpolation subroutine
(\texttt{interpxyz}) are the same as in the {\sc diag} program,
the subroutines of reading and writing are those for handling diachronic files
(\texttt{readvar} and \texttt{writevar}).
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 0 676 567 842
%%Title: fic1
%%CreationDate: Wed Apr 2 12:35:31 2008
%%Creator: Tgif-4.1.45-QPL written by William Chia-Wei Cheng (bill.cheng@acm.org)
%%ProducedBy: (unknown)
%%Pages: 1
%%DocumentFonts: (atend)
%%EndComments
%%BeginProlog
/tgifdict 86 dict def
tgifdict begin
/tgifarrowtipdict 8 dict def
tgifarrowtipdict /mtrx matrix put
/TGAT % tgifarrowtip
{ tgifarrowtipdict begin
/dy exch def
/dx exch def
/h exch def
/w exch def
/y exch def
/x exch def
/savematrix mtrx currentmatrix def
x y translate
dy dx atan rotate
0 0 moveto
w neg h lineto
w neg h neg lineto
savematrix setmatrix
end
} def
/tgifpatdict 10 dict def
/tgifpatbyte
{ currentdict /retstr get exch
pat i cellsz mod get put
} def
/tgifpatproc
{ 0 1 widthlim {tgifpatbyte} for retstr
/i i 1 add def
} def
/TGPF % tgifpatfill
{ tgifpatdict begin
/h exch def
/w exch def
/lty exch def
/ltx exch def
/cellsz exch def
/pat exch def
/widthlim w cellsz div cvi 1 sub def
/retstr widthlim 1 add string def
/i 0 def
tgiforigctm setmatrix
ltx lty translate
w h true [1 0 0 1 0 0] {tgifpatproc} imagemask
ltx neg lty neg translate
end
} def
/pat3 <8000000008000000> def
/pat4 <8800000022000000> def
/pat5 <8800220088002200> def
/pat6 <8822882288228822> def
/pat7 <aa55aa55aa55aa55> def
/pat8 <77dd77dd77dd77dd> def
/pat9 <77ffddff77ffddff> def
/pat10 <77ffffff77ffffff> def
/pat11 <7fffffff7fffffff> def
/pat12 <8040200002040800> def
/pat13 <40a00000040a0000> def
/pat14 <ff888888ff888888> def
/pat15 <ff808080ff080808> def
/pat16 <f87422478f172271> def
/pat17 <038448300c020101> def
/pat18 <081c22c180010204> def
/pat19 <8080413e080814e3> def
/pat20 <8040201008040201> def
/pat21 <8844221188442211> def
/pat22 <77bbddee77bbddee> def
/pat23 <c1e070381c0e0783> def
/pat24 <7fbfdfeff7fbfdfe> def
/pat25 <3e1f8fc7e3f1f87c> def
/pat26 <0102040810204080> def
/pat27 <1122448811224488> def
/pat28 <eeddbb77eeddbb77> def
/pat29 <83070e1c3870e0c1> def
/pat30 <fefdfbf7efdfbf7f> def
/pat31 <7cf8f1e3c78f1f3e> def
/TGMAX
{ exch dup 3 1 roll exch dup 3 1 roll gt { pop } { exch pop } ifelse
} def
/TGMIN
{ exch dup 3 1 roll exch dup 3 1 roll lt { pop } { exch pop } ifelse
} def
/TGSW { stringwidth pop } def
/bd { bind def } bind def
/GS { gsave } bd
/GR { grestore } bd
/NP { newpath } bd
/CP { closepath } bd
/CHP { charpath } bd
/CT { curveto } bd
/L { lineto } bd
/RL { rlineto } bd
/M { moveto } bd
/RM { rmoveto } bd
/S { stroke } bd
/F { fill } bd
/TR { translate } bd
/RO { rotate } bd
/SC { scale } bd
/MU { mul } bd
/DI { div } bd
/DU { dup } bd
/NE { neg } bd
/AD { add } bd
/SU { sub } bd
/PO { pop } bd
/EX { exch } bd
/CO { concat } bd
/CL { clip } bd
/EC { eoclip } bd
/EF { eofill } bd
/IM { image } bd
/IMM { imagemask } bd
/ARY { array } bd
/SG { setgray } bd
/RG { setrgbcolor } bd
/SD { setdash } bd
/W { setlinewidth } bd
/SM { setmiterlimit } bd
/SLC { setlinecap } bd
/SLJ { setlinejoin } bd
/SH { show } bd
/FF { findfont } bd
/MS { makefont setfont } bd
/AR { arcto 4 {pop} repeat } bd
/CURP { currentpoint } bd
/FLAT { flattenpath strokepath clip newpath } bd
/TGSM { tgiforigctm setmatrix } def
/TGRM { savematrix setmatrix } def
end
%%EndProlog
%%Page: 1 1
%%PageBoundingBox: 0 676 567 842
tgifdict begin
/tgifsavedpage save def
1 SM
1 W
0 SG
72 0 MU 72 11.695 MU TR
72 128 DI 100.000 MU 100 DI DU NE SC
GS
/tgiforigctm matrix currentmatrix def
% TEXT
NP
0 SG
GS
1 W
368 16 M
GS
0 SG
/Courier FF [17 0 0 -17 0 0] MS
(prepmodel MAINPROG=) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
160 64 M
GS
GS
0
/Helvetica FF [14 0 0 -14 0 0] MS
(PREP_PGD) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Helvetica FF [14 0 0 -14 0 0] MS
(PREP_PGD) SH
GR
0 17 RM
GS
GS
0
/Helvetica FF [14 0 0 -14 0 0] MS
(PREP_NEST_PGD) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Helvetica FF [14 0 0 -14 0 0] MS
(PREP_NEST_PGD) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
336 64 M
GS
GS
0
/Helvetica FF [14 0 0 -14 0 0] MS
(PREP_IDEAL_CASE) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Helvetica FF [14 0 0 -14 0 0] MS
(PREP_IDEAL_CASE) SH
GR
0 17 RM
GS
GS
0
/Helvetica FF [14 0 0 -14 0 0] MS
(PREP_REAL_CASE) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Helvetica FF [14 0 0 -14 0 0] MS
(PREP_REAL_CASE) SH
GR
0 17 RM
GS
GS
0
/Helvetica FF [14 0 0 -14 0 0] MS
(DIAG) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Helvetica FF [14 0 0 -14 0 0] MS
(DIAG) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
640 64 M
GS
GS
0
/Helvetica FF [14 0 0 -14 0 0] MS
(MODEL) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Helvetica FF [14 0 0 -14 0 0] MS
(MODEL) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
160 160 M
GS
GS
0
/Times-Roman FF [14 0 0 -14 0 0] MS
(physiographic output) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Times-Roman FF [14 0 0 -14 0 0] MS
(physiographic output) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
320 160 M
GS
GS
0
/Times-Roman FF [14 0 0 -14 0 0] MS
(synchronous output) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Times-Roman FF [14 0 0 -14 0 0] MS
(synchronous output) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
576 160 M
GS
GS
0
/Times-Roman FF [14 0 0 -14 0 0] MS
(synchronous outputs) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Times-Roman FF [14 0 0 -14 0 0] MS
(synchronous outputs) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
864 160 M
GS
GS
0
/Times-Roman FF [14 0 0 -14 0 0] MS
(diachronic output) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Times-Roman FF [14 0 0 -14 0 0] MS
(diachronic output) SH
GR
GR
% TEXT
NP
0 SG
GS
NP 137 161 M 183 161 L 183 180 L 137 180 L CP 1 SG F
0 SG
NP 137 161 M 183 161 L 183 180 L 137 180 L CP EC NP
pat26 8 136 160 56 24 TGPF
GR
GS
1 W
160 176 M
GS
GS
0
/Times-Italic FF [14 0 0 -14 0 0] MS
(PGD.lfi) TGSW
AD
GR
2 DI NE 0 RM
1.000 0.000 0.000 RG
/Times-Italic FF [14 0 0 -14 0 0] MS
(PGD.lfi) SH
GR
GR
% TEXT
NP
0 SG
GS
NP 329 193 M 375 193 L 375 212 L 329 212 L CP 1 SG F
0 SG
NP 329 193 M 375 193 L 375 212 L 329 212 L CP EC NP
pat26 8 328 192 56 24 TGPF
GR
GS
1 W
352 208 M
GS
GS
0
/Times-Italic FF [14 0 0 -14 0 0] MS
(INIT.lfi) TGSW
AD
GR
2 DI NE 0 RM
1.000 0.000 0.000 RG
/Times-Italic FF [14 0 0 -14 0 0] MS
(INIT.lfi) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
272 208 M
GS
GS
0
/Times-Italic FF [14 0 0 -14 0 0] MS
(INIT.des) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Times-Italic FF [14 0 0 -14 0 0] MS
(INIT.des) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
496 208 M
GS
GS
0
/Times-Italic FF [14 0 0 -14 0 0] MS
(CEXP.1.CSEG.00n.des) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Times-Italic FF [14 0 0 -14 0 0] MS
(CEXP.1.CSEG.00n.des) SH
GR
GR
% TEXT
NP
0 SG
GS
NP 577 193 M 702 193 L 702 212 L 577 212 L CP 1 SG F
0 SG
NP 577 193 M 702 193 L 702 212 L 577 212 L CP EC NP
pat26 8 576 192 128 24 TGPF
GR
GS
1 W
640 208 M
GS
GS
0
/Times-Italic FF [14 0 0 -14 0 0] MS
(CEXP.1.CSEG.00n.lfi) TGSW
AD
GR
2 DI NE 0 RM
1.000 0.000 0.000 RG
/Times-Italic FF [14 0 0 -14 0 0] MS
(CEXP.1.CSEG.00n.lfi) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
800 208 M
GS
GS
0
/Times-Italic FF [14 0 0 -14 0 0] MS
(CEXP.1.CSEG.000.des) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Times-Italic FF [14 0 0 -14 0 0] MS
(CEXP.1.CSEG.000.des) SH
GR
GR
% TEXT
NP
0 SG
GS
NP 881 193 M 1006 193 L 1006 212 L 881 212 L CP 1 SG F
0 SG
NP 881 193 M 1006 193 L 1006 212 L 881 212 L CP EC NP
pat4 8 880 192 128 24 TGPF
GR
GS
1 W
944 208 M
GS
GS
0
/Times-Italic FF [14 0 0 -14 0 0] MS
(CEXP.1.CSEG.000.lfi) TGSW
AD
GR
2 DI NE 0 RM
0.000 0.000 1.000 RG
/Times-Italic FF [14 0 0 -14 0 0] MS
(CEXP.1.CSEG.000.lfi) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
48 192 M
GS
GS
0
/Courier FF [12 0 0 -12 0 0] MS
(fm2deslfi) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Courier FF [12 0 0 -12 0 0] MS
(fm2deslfi) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
320 176 M
GS
GS
0
/Times-Italic FF [14 0 0 -14 0 0] MS
(INIT) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Times-Italic FF [14 0 0 -14 0 0] MS
(INIT) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
576 176 M
GS
GS
0
/Times-Italic FF [14 0 0 -14 0 0] MS
(CEXP.1.CSEG.00n) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Times-Italic FF [14 0 0 -14 0 0] MS
(CEXP.1.CSEG.00n) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
864 176 M
GS
GS
0
/Times-Italic FF [14 0 0 -14 0 0] MS
(CEXP.1.CSEG.000) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Times-Italic FF [14 0 0 -14 0 0] MS
(CEXP.1.CSEG.000) SH
GR
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
336 176 M
16 16 atan DU cos 8.000 MU 352 exch SU
exch sin 8.000 MU 192 exch SU L
TGSM
1 W
S
GR
GS
TGSM
NP
352 192 8.000 3.000 16 16 TGAT
1 SG CP F
0 SG
NP
352 192 8.000 3.000 16 16 TGAT
CP F
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
640 176 M
16 16 atan DU cos 8.000 MU 656 exch SU
exch sin 8.000 MU 192 exch SU L
TGSM
1 W
S
GR
GS
TGSM
NP
656 192 8.000 3.000 16 16 TGAT
1 SG CP F
0 SG
NP
656 192 8.000 3.000 16 16 TGAT
CP F
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
928 176 M
16 16 atan DU cos 8.000 MU 944 exch SU
exch sin 8.000 MU 192 exch SU L
TGSM
1 W
S
GR
GS
TGSM
NP
944 192 8.000 3.000 16 16 TGAT
1 SG CP F
0 SG
NP
944 192 8.000 3.000 16 16 TGAT
CP F
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
800 176 M
16 -16 atan DU cos 8.000 MU 784 exch SU
exch sin 8.000 MU 192 exch SU L
TGSM
1 W
S
GR
GS
TGSM
NP
784 192 8.000 3.000 -16 16 TGAT
1 SG CP F
0 SG
NP
784 192 8.000 3.000 -16 16 TGAT
CP F
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
512 176 M
16 -16 atan DU cos 8.000 MU 496 exch SU
exch sin 8.000 MU 192 exch SU L
TGSM
1 W
S
GR
GS
TGSM
NP
496 192 8.000 3.000 -16 16 TGAT
1 SG CP F
0 SG
NP
496 192 8.000 3.000 -16 16 TGAT
CP F
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
304 176 M
16 -16 atan DU cos 8.000 MU 288 exch SU
exch sin 8.000 MU 192 exch SU L
TGSM
1 W
S
GR
GS
TGSM
NP
288 192 8.000 3.000 -16 16 TGAT
1 SG CP F
0 SG
NP
288 192 8.000 3.000 -16 16 TGAT
CP F
GR
% TEXT
NP
0 SG
GS
NP 109 273 M 483 273 L 483 292 L 109 292 L CP 1 SG F
0 SG
NP 109 273 M 483 273 L 483 292 L 109 292 L CP EC NP
pat26 8 104 272 384 24 TGPF
GR
GS
1 W
296 288 M
GS
GS
0
/Times-Bold FF [14 0 0 -14 0 0] MS
(synchronuous files: PGD.lfi, INIT.lfi, CEXP.1.CSEG.00n.lfi) TGSW
AD
GR
2 DI NE 0 RM
1.000 0.000 0.000 RG
/Times-Bold FF [14 0 0 -14 0 0] MS
(synchronuous files: PGD.lfi, INIT.lfi, CEXP.1.CSEG.00n.lfi) SH
GR
GR
% TEXT
NP
0 SG
GS
NP 658 273 M 894 273 L 894 292 L 658 292 L CP 1 SG F
0 SG
NP 658 273 M 894 273 L 894 292 L 658 292 L CP EC NP
pat4 8 656 272 240 24 TGPF
GR
GS
1 W
776 288 M
GS
GS
0
/Times-Bold FF [14 0 0 -14 0 0] MS
(diachronic file: CEXP.1.CSEG.000.lfi) TGSW
AD
GR
2 DI NE 0 RM
0.000 0.000 1.000 RG
/Times-Bold FF [14 0 0 -14 0 0] MS
(diachronic file: CEXP.1.CSEG.000.lfi) SH
GR
GR
% POLY/OPEN-SPLINE
0 SG
GS
[4 4] 0 SD
NP
240 32 M
240 152 L
TGSM
1 W
S
[] 0 SD
GR
% POLY/OPEN-SPLINE
0 SG
GS
[4 4] 0 SD
NP
416 32 M
416 152 L
TGSM
1 W
S
[] 0 SD
GR
% TEXT
NP
0 SG
GS
1 W
64 208 M
GS
GS
0
/Times-Roman FF [14 0 0 -14 0 0] MS
(\() TGSW
AD
/Times-Roman FF [12 0 0 -12 0 0] MS
(on the computer where ) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Times-Roman FF [14 0 0 -14 0 0] MS
(\() SH
0 SG
/Times-Roman FF [12 0 0 -12 0 0] MS
(on the computer where ) SH
GR
0 15 RM
GS
GS
0
/Times-Roman FF [12 0 0 -12 0 0] MS
( the file was created\)) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Times-Roman FF [12 0 0 -12 0 0] MS
( the file was created\)) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
576 112 M
GS
GS
0
/Times-Roman FF [12 0 0 -12 0 0] MS
(t1,t2,...,tn) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Times-Roman FF [12 0 0 -12 0 0] MS
(t1,t2,...,tn) SH
GR
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
552 120 M
24 0 atan DU cos 8.000 MU 552 exch SU
exch sin 8.000 MU 144 exch SU L
TGSM
1 W
S
GR
GS
TGSM
NP
552 144 8.000 3.000 0 24 TGAT
1 SG CP F
0 SG
NP
552 144 8.000 3.000 0 24 TGAT
CP F
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
568 120 M
24 0 atan DU cos 8.000 MU 568 exch SU
exch sin 8.000 MU 144 exch SU L
TGSM
1 W
S
GR
GS
TGSM
NP
568 144 8.000 3.000 0 24 TGAT
1 SG CP F
0 SG
NP
568 144 8.000 3.000 0 24 TGAT
CP F
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
592 120 M
24 0 atan DU cos 8.000 MU 592 exch SU
exch sin 8.000 MU 144 exch SU L
TGSM
1 W
S
GR
GS
TGSM
NP
592 144 8.000 3.000 0 24 TGAT
1 SG CP F
0 SG
NP
592 144 8.000 3.000 0 24 TGAT
CP F
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
800 120 M
872 120 L
24 0 atan DU cos 8.000 MU 872 exch SU
exch sin 8.000 MU 144 exch SU L
TGSM
1 W
S
GR
GS
TGSM
NP
872 144 8.000 3.000 0 24 TGAT
1 SG CP F
0 SG
NP
872 144 8.000 3.000 0 24 TGAT
CP F
GR
% TEXT
NP
0 SG
GS
1 W
880 120 M
GS
GS
0
/Times-Roman FF [12 0 0 -12 0 0] MS
(t) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Times-Roman FF [12 0 0 -12 0 0] MS
(t) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
328 116 M
GS
GS
0
/Times-Roman FF [12 0 0 -12 0 0] MS
(t0) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Times-Roman FF [12 0 0 -12 0 0] MS
(t0) SH
GR
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
328 120 M
24 0 atan DU cos 8.000 MU 328 exch SU
exch sin 8.000 MU 144 exch SU L
TGSM
1 W
S
GR
GS
TGSM
NP
328 144 8.000 3.000 0 24 TGAT
1 SG CP F
0 SG
NP
328 144 8.000 3.000 0 24 TGAT
CP F
GR
% TEXT
NP
0 SG
GS
1 W
160 116 M
GS
GS
0
/Times-Roman FF [12 0 0 -12 0 0] MS
(t0) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Times-Roman FF [12 0 0 -12 0 0] MS
(t0) SH
GR
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
160 120 M
24 0 atan DU cos 8.000 MU 160 exch SU
exch sin 8.000 MU 144 exch SU L
TGSM
1 W
S
GR
GS
TGSM
NP
160 144 8.000 3.000 0 24 TGAT
1 SG CP F
0 SG
NP
160 144 8.000 3.000 0 24 TGAT
CP F
GR
GR
tgifsavedpage restore
end
showpage
%%Trailer
%MatchingCreationDate: Wed Apr 2 12:35:31 2008
%%DocumentFonts: Times-Bold
%%+ Times-Italic
%%+ Times-Roman
%%+ Helvetica
%%+ Courier
%%EOF
\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:
\section{Conversion to GRIB or Vis5D files}
\subsection{Presentation}
FM synchronous file can be convert into \underline{GRIB}
or \underline{Vis5D} format.
This section aims at describ how the converter works and how use it.
The GRIB (GRId in Binary) format is a standard meteorological one, defined
by the WMO. GRIB files can be plotted with METVIEW
%\footnote{available on {\tt xdata} workstation in CNRM}
graphic interface (developped at ECMWF), or
R2\footnote{used in the GMME/MICADO team at CNRM} software.
The Vis5D format is specified for using Vis5D\footnote{home page
{\tt http://www.ssec.wisc.edu/\~ billh/vis5d.html}}
software (following the GNU General Public License): 3 spatial
dimensions, time dimension, 5$^{th}$ dimension for enumeration of variables.
It is rather designed for animation of 3D plotting.
Choice was made to put together the two file formats in a same conversion
program because in both cases specificities of Meso-NH grids have to be
treated in the same way (horizontally: Arakawa C-grid, vertically: Gal-Chen
coordinate $\hat z$ following terrain). However, the user has to choose one
of the two formats available when running the tool
(see section \ref{s:execution}).
\subsection{Usage} \label{s:execution}
The interactive tool is
called {\tt lfi2grb} or {\tt lfi2v5d} according the wanted output
file format, but it runs the same program. Some questions are to be
answered to indicate the number and type of vertical levels, the type of
horizontal domain,
and the name of the variables to write into the output file.
All that is typed on keyboard is saved in {\tt dirconv.grb} or {\tt dirconv.v5d}
file, it can be appended and used as input (after renaming it) for the next call
of the tool (e.g. {\tt mv dirconv.grb dirgrb ; lfi2grb < dirgrb}).
For historical reasons, a program with the same goal of conversion to GRIB or
Vis5d has been first developped as a main program
of MesoNH, as DIAG program is. This program called {\bf CONVLFI} runs with
the MesoNH procedure {\bf prepmodel} and
a namelist file {\tt CONVLFI1.nam} (see \ref{ss:convlfi}).
To use the converter after a {\bf DIAG prepmodel} job, the Meso-NH file must
remain a synchronous file, not transformed onto a diachronic file:
in {\bf prepmodelrc} specify {\tt OUTFILE\_TOOLS='fm'}
(default is 'conv2dia' to convert with {\tt conv2dia}).
\subsubsection{{\tt lfi2grb} tool}
When {\tt lfi2grb} tool is invoked, you must indicate,
after the name of the input file, first
the horizontal grid (type, eventually type of interpolation and domain),
the vertical grid (type and levels),
then the list of the 3-dimensional fields to convert,
and the list of the 2-dimensional ones.
For the \underline{horizontal grid}, you can either keep the one of MesoNH file
(cartesien or conformal projection) or interpolate onto a lat-lon regular grid.
In the first case, you can replace all the fields on mass points (A-grid)
or keep the native grid (C-grid).
In the second case, you have to indicate
the bounds of the domain with north and south latitudes and west and east
longitudes, as well as the type of horizontal interpolation:
nearest-neighbour value or bilinear interpolation with the 4 surrounding values.
The resolution of the lat.-lon. grid is automatically initialized
with the equivalent value of the grid-mesh where the map scale is minimum.
The program also indicates the number of grid points of the Meso-NH domain
inside the prescribed lat-lon domain. If there are points of lat-lon domain
outside Meso-NH one, the value of the interpolated fields at these points
will be a missing one.
The \underline{vertical grid} can be either the native K levels or pressure
levels.
In the first case ({\tt K}), all levels are kept and no interpolation is done:
the height specified in the GRIB header is the one of the grid without orography.
In the second case ({\tt P}), the list of pressure levels is either specified
manually or computed using a linear function from user-specified
minimum, maximum and increment values. If a prescribed level is below the lower
Meso-NH level or above the upper MesoNH level, the value of the field at this
level will be a missing one. Otherwise, the value is computed from
a linear interpolation in log(P).
The \underline{3-dimensional fields} to convert are specified as follows:
one field per line with first the name of the record in the input file
following by its grib code (tabular character is allowed). Note that no test
is done on the value of grib code (GRIB header {\sf ISEC1(6)}): you choose it
to easily identify the field with the software used after the conversion.
The end of the list is indicated by the keyword {\tt END}.
The \underline{2-dimensional fields} to convert are specified as follows:
one field per line with first the name of the record in the input file
(it can be a K-level of a 3-dimensional field too),
following by its grib code and possibly level indicator and level value
(tabular character is allowed).
Note that the value of the level indicator ({\sf ISEC1(7)}) is optional
(the default value is 105: {\sf 'specified height above ground'}).
So is the level value ({\sf ISEC1(8)}), the default value is the altitude of
the first mass point of the K-levels.
The end of the list is indicated by the keyword {\tt END}.
\subsubsection{Example of {\tt lfi2grb} use}
\begin{itemize}
\item to convert onto a GRIB file with horizontal and vertical interpolations in P levels:\\
(all that is typed on keyboard (in {\it italic} in the example below)
is saved in {\tt dirconv.grb})
\end{itemize}
\small
{\tt - ENTER FM synchronous FILE NAME (without .lfi) ?} \\
{\tt\it CEXP.1.CSEG.001d } \hspace{3.5cm} $<$- the input file must be splitted in .des and .lfi \\
{\tt - Horizontal interpolation to lat-lon regular grid? (Y/y/O/o/N/n)}\\
{\tt\it y } \\
{\tt - Type of interpolation? NEARest-neighbour (default) or BILInear }\\
{\tt\it NEAR } \\
{\tt - NSWE target domain bounds (in degrees)? }\\
{\tt\it 55. 35. -20. 10. } \\
{\tt - Vertical grid: type K or P ? }\\
{\tt\it P } \\
{\tt - Type of vertical grid: given by linear FUNCTN (default) or MANUALly ?}\\
{\tt\it FUNCTN } \\
{\tt - Enter number of P levels ?} \\
{\tt\it 5 } \\
{\tt - Values of the 5 P levels (hPa, from bottom to top):} \\
{\tt\it 1000. 850. 700. 500. 300. } \\
{\tt - Enter 3D variables to CONVERT (1/1 line, end by END): }\\
{\tt MesoNH field name, grib parameter indicator }\\
{\tt\it UM 33 }\\
{\tt - next 3D field or END ? }\\
{\tt\it VM 34 }\\
{\tt - next 3D field or END ? }\\
{\tt\it END }\\
{\tt - Enter 2D variables to CONVERT (1/1 line, end by END): }\\
{\tt MesoNH field name, grib parameter indicator, eventually level indicator and level value}\\
{\tt\it T2M 13 105 2}\\
{\tt - next 2D field or END ? }\\
{\tt\it THM\_K\_2 13}\\
{\tt - next 2D field or END ? }\\
{\tt\it END}\\
{\tt 2 fields (3D), and 2 fields (2D) written in CEXP.1.CSEG.001d.GRB }\\
\normalsize
\subsubsection{{\tt lfi2v5d} tool}
When {\tt lfi2v5d} tool is invoked, you must indicate,
after the name of the input file, first
the vertical grid (type and levels),
then the list of the 3-dimensional fields to convert,
and the list of the 2-dimensional ones.
No horizontal interpolation is available for the Vis5D format output: all the
converted fields are replaced on mass points (A-grid) of the MesoNH grid
(cartesien or conformal projection).
The \underline{vertical grid} can be either the native K levels, altitude
levels or pressure levels.
In the first case ({\tt K}), all levels are kept and the fields are interpolated
on the levels of the lowest point of the domain.
In the second and third cases ({\tt Z} and {\tt P}), the list of levels is
either specified
manually or computed using a linear function from user-specified
minimum, maximum and increment values. The value of the field is computed from
a linear interpolation in Z or in log(P).
The \underline{3-dimensional fields} to convert are specified with
one record name per line.
The end of the list is indicated by the keyword {\tt END}.
Then the \underline{2-dimensional fields},
or a K-level of 3-dimensional fields,
to convert are specified in the same way.
\subsubsection{Example of {\tt lfi2v5d} use}
\begin{itemize}
\item to convert onto a Vis5D file with vertical interpolation in Z levels:\\
(all that is typed on keyboard (in {\it italic} in the example below)
is saved in {\tt dirconv.v5d})
\end{itemize}
\small
{\tt - ENTER FM synchronous FILE NAME (without .lfi) ?} \\
{\tt\it CEXP.1.CSEG.001 } \hspace{3.5cm} $<$- the input file must be splitted in .des and .lfi \\
{\tt - Verbosity level ?} \\
{\tt\it 5 } \\
{\tt - File 2D (xz): L2D=T or F ?} \\
{\tt\it F } \\
{\tt - Vertical grid: type K,Z or P ?} \\
{\tt\it Z } \\
{\tt - Type of vertical grid: given by linear FUNCTN (default) or MANUALly ?} \\
{\tt\it FUNCTN } \\
{\tt - Vertical grid: min, max, int (m for Z, hPa for P)?} \\
{\tt\it 1500 9000 3000 } \\
{\tt - Enter 3D variables to CONVERT (1/1 line, end by END): }\\
{\tt\it THM } \\
{\tt - next 3D field or END ? }\\
{\tt\it POVOM } \\
{\tt - next 3D field or END ? }\\
{\tt\it END }\\
{\tt - Enter 2D variables to CONVERT (1/1 line, end by END): }\\
{\tt\it ZS } \\
{\tt - next 2D field or END ? }\\
{\tt\it END }\\
{\tt 2 fields (3D), and 1 fields (2D) written in CEXP.1.CSEG.001d.V5D }\\
\subsubsection{{\bf CONVLFI} program} \label{ss:convlfi}
The MesoNH program {\bf CONVLFI} allows conversion onto GRIB
(the horizontal grid is either the native
MesoNH grid (Arakawa C-grid) of the field, the MesoNH mass grid
(Arakawa A-grid),
the vertical grid is either the native K levels or pressure levels), or
conversion onto Vis5D (the horizontal grid is the MesoNH mass grid
(A-grid), the vertical grid is either the native K levels without orography,
altitude or pressure levels).
The conversion is done with the Meso--NH procedure {\bf prepmodel} used with
the {\bf CONVLFI} program and the {\tt CONVLFI1.nam} namelist file.
Up to 24 FM files can be treated identically in a single prepmodel job.
\\
A) In the file \underline{\bf prepmodelrc}, the input and output host, directories
and login control variables refer to the input and output files as usual.
The other control variables to initialize specifically in this file are:
\begin{itemize}
\item MAINPROG=CONVLFI
\item LOAD\_OPT='location\_of\_v5d\_library'
\item OUTHOST=name\_workstation (for example) \\
this allows future use of {\tt vis5d} or {\tt metview} on your local host.
\end{itemize}
B) In the \underline{\tt CONVLFI1.nam} namelist file, the user must indicate
the format type wanted, the number and type of vertical levels,
the type of horizontal interpolation on a lat/lon domain
as well as the name of the variables to write into the output file:
\begin{enumerate}
\item\underline{Namelist NAM\_OUTFILE}:
\begin{center}
\begin{tabular} {|l|l|l|}
\hline
Fortran name & Fortran type & default value\\
\hline
\hline
CMNHFILE & array of character (len=28) & none \\
COUTFILETYPE & character (len=3) & none \\
NVERB & integer & 5 \\
LAGRID & logical & .TRUE. \\
CLEVTYPE & character (len=1) & 'P' if COUTFILETYPE='GRB' \\
& & 'K' if COUTFILETYPE='V5D' \\
CLEVLIST & character (len=6) & 'FUNCTN' \\
XVLMIN & real & 10000. if COUTFILETYPE='GRB' \\
XVLMAX & real & 100000. if COUTFILETYPE='GRB' \\
XVLINT & real & 10000. if COUTFILETYPE='GRB' \\
LLMULTI & logical & .TRUE. \\
\hline
\end{tabular}
\end{center}
\begin{itemize}
\item CMNHFILE: name of the input FM file (from an initialization sequence, or
a model simulation, or after diagnostics computation).
\index{CMNHFILE!\innam{NAM\_OUTFILE}}
\item COUTFILETYPE: type of the output file, appended
to CMNHFILE to generate the name of the output file.
\begin{itemize}
\item 'V5D'
\item 'GRB'
\end{itemize}
\index{COUTFILETYPE!\innam{NAM\_OUTFILE}}
\item NVERB: verbosity level
\begin{itemize}
\item 0 for minimum of prints
\item 5 for intermediate level of prints
\item 10 for maximum of prints.
\end{itemize}
\index{NVERB!\innam{NAM\_OUTFILE}}
\item LAGRID: switch to interpolate fields on an Arakawa A-grid (mass grid),
\subitem forced to .TRUE. if Vis5D file or horizontal interpolation.
\index{LAGRID!\innam{NAM\_OUTFILE}}
\item CLEVTYPE: type of vertical levels in output file,
\index{CLEVTYPE!\innam{NAM\_OUTVER}}
\begin{itemize}
\item 'P' pressure levels
\item 'Z' z levels (only used for COUTFILETYPE='V5D')
\item 'K'
\subitem if COUTFILETYPE='GRB': native vertical grid of Meso-NH (no
interpolation, height specified in GRIB message is the one of the grid
without orography),
\subitem if COUTFILETYPE='V5D': native vertical grid of Meso-NH (fields are
interpolated on the levels of the lowest point of the domain).
\end{itemize}
\item CLEVLIST: how vertical levels are specified
\begin{itemize}
\item 'MANUAL' number and list of levels specified in the 1$^{st}$ free-format
part,
\item 'FUNCTN' using a linear function, with the next 3 parameters.
\end{itemize}
\index{CLEVLIST!\innam{NAM\_OUTVER}}
\item XVLMIN: minimum value for the vertical grid
\subitem (in m for CLEVTYPE = 'Z', in Pa for CLEVTYPE = 'P'),
\item XVLMAX: maximum value for the vertical grid (`'),
\item XVLINT: increment value for the vertical grid (`').
\item LLMULTI: switch to produce a multigrib file (.T.) or monogrib files (.F.),
only used for COUTFILETYPE='GRB' (each monogrib file name is composed with the
date, the variable name and the level).
\index{LLMULTI!\innam{NAM\_OUTFILE}}
\end{itemize}
\item\underline{Free-format part}: (number and list of vertical levels) \\
This part is only used if CLEVLIST='MANUAL':
\begin{enumerate}
\item first the number of vertical levels,
\item then the list of levels, by increasing values in m if CLEVTYPE = 'Z', or decreasing
values in Pa if CLEVTYPE = 'P'
\end{enumerate}
\item\underline{Free-format part}: (variable names)
This part indicates the record name of the variables of the input file to
write in the output file. It is specified in two parts:
\begin{enumerate}
\item between the keywords BEGIN\_3D and END\_3D: the name of the 3D fields,
following by their grib code if COUTFILETYPE='GRB' (separed by tabular
character).
\item between the keywords BEGIN\_2D and END\_2D: the name of the 2D fields,
following by their grib code, and possibly level indicator and level value
if COUTFILETYPE='GRB' (separed by tabular character).
\end{enumerate}
{\bf N.B.:} do not forget the comment line after the keyword BEGIN\_3D
and BEGIN\_2D.
\end{enumerate}
\underline{C) Example of namelist file CONVLFI1.nam}
\begin{itemize}
\item
to convert into a Vis5d file:
\end{itemize}
\begin{verbatim}
&NAM_OUTFILE CMNHFILE(1)='T1E20.2.09B24.002',
CMNHFILE(2)='T1E20.2.09B24.003',
COUTFILETYPE='V5D',
CLEVTYPE='Z', CLEVLIST='MANUAL',
LAGRID=T, NVERB=10 /
15
30.
100.
250.
500.
1000.
1500.
2000.
2500.
3000.
3500.
4000.
4500.
5000.
6000.
8000.
BEGIN_3D
#variables 3D (MesoNH field name)
UM
VM
WM
THM
END_3D
BEGIN_2D
#variables 2D (MesoNH field name)
ZS
END_2D
\end{verbatim}
\begin{itemize}
\item
to convert into a GRIB file:
\end{itemize}
\begin{verbatim}
&NAM_OUTFILE CMNHFILE(1)='T1E20.2.09B24.002',
CMNHFILE(2)='T1E20.2.09B24.003',
COUTFILETYPE='GRB',
CLEVTYPE='P', CLEVLIST='FUNCTN',
XVLMAX=100000., XVLMIN=10000., XVLINT=10000.,
LAGRID=T, NVERB=5 /
BEGIN_3D
#variables 3D (MesoNH field name, grib parameter indicator)
UM 33
VM 34
WM 40
THM 13
END_3D
BEGIN_2D
#variables 2D (MesoNH field name, grib parameter indicator)
ZS 8
END_2D
next lines are ignored
codes example:
MSLP 1
ACPRR 61
INPRR 59
PABSM 1
ALT 6
TEMP 11
REHU 52
RVM 53
RCM 153
RRM 170
RIM 178
RSM 171
RGM 179
RHM 226
RARE 230
HHRE 231
VVRE 232
VDOP 233
POVOM 234
\end{verbatim}
\normalsize
\subsection{Short description of the program}
Two main tasks are performed by the program:
\begin{enumerate}
\item \subitem After the specification of the name of the input file, a `light'
initialization subroutine {\tt init\_for\_convlfi.f90 } is called to initialize
the I/O interface, the geometry, dimensions, grids, metric coefficients, times,
and to read pressure field.
\subitem According the output grids choosen, extra arrays are allocated for
interpolations.
\ignore{
If horizontal interpolation is required, the equivalent
resolution and the number of usefull points are computed by the subroutine
{\tt ini2lalo.f90}.
}%ignore
\item Then fields are treated one after another: first 3D fields, then
2D fields.
\subitem In the case of GRIB conversion, fields are interpolated and written
one after another (subroutine {\tt code\_and\_write\_grib.f90 } called for each
horizontal level of each field).
\subitem For Vis5D conversion, fields are interpolated and written
all together (subroutine \newline {\tt code\_and\_write\_vis5d.f90 } called at the end).
\end{enumerate}
Using a `light' initialization routine and reading fields name from standard
input allows the conversion program not to be dependant of a MesoNH version
or program.
\subsection{Some tips to use Vis5D}
See the complete guide for using Vis5D: file README.ps in the Vis5D package.
\subsubsection{Utilities} (section 5 of README.ps)
\begin{itemize}
\item
{\tt v5dinfo filename}: shows summary of the v5d file: number and name of
the variables, size of the 3-D grid, number of time steps, vertical
grid definition and projection definition.
\item
{\tt v5dstats filename}: shows statistics of the v5d file:
minimum value, maximum value, mean value, standard deviation of
each variable.
\item
{\tt v5dedit filename}: edits the header of the v5d file and allows to change
it: variables names, variables units, times and dates, projection, vertical
coordinate system, low levels. \\
{\it Useful to set the variable's units since they are not set by the program
CONVLFI.}
\item
{\tt v5dappend [-var] filename1 ... targetfile}: joins v5d files together:
{\it useful since the {\bf prepmodel} job generates a separate v5d file for each
timestep}, {\tt var} indicates list of variables to omit in the target file,
the dimensions of 3-D grids must be the same in each input file.
\end{itemize}
\subsubsection{Options} \label{ss:opt} (section 6.1 of README.ps) \\
To call Vis5D: {\tt vis5d file1 [options] file2 [options] ...} \\
Options can be be specified here when calling, or by pressing the {\sf DISPLAY}
button of the main control panel and then the 'Options' menu.
Options useful to set when calling: \\
{\tt [-date]} use 'dd month yy' instead of julian 'yyddd' date, \\
{\tt [-box x y z]} specify the aspect ratio of the 3-D box (default is 2 2 1), \\
{\tt [-mbs n]} override the assumed system memory size of 32 megabytes (Vis5D
tells you value to specify if not enough), \\
{\tt [-topo file]} use a topography file other than the default EARTH.TOPO
\subsubsection{Control panel} (section 6.2 of README.ps) \\
The top buttons control primary functions of Vis5D (see section
\ref{sss:funct}). \\
The middle ones control the viewing modes (see section \ref{sss:viewing}).\\
The bottom 2-D matrix of buttons contains physical variables on the rows, and
types of graphic representation on the columns. To control any type of graphic,
click on the button with the left mouse button.
A pop-up window appears when clicking with the middle mouse button, and
one window to modify colors with the right button
(see section \ref{sss:graph}).
\\
\underline{\bf Primary functions} \label{sss:funct}(section 6.3 of README.ps)
\begin{itemize}
\item{\sf SAVE PIC} to save the image in a file: first toggle the {\sf REVERSE}
button to reverse black and white, then toggle the {\sf SAVE PIC} button and
choose {\tt xwd} (X Window Dump) format. The file can be visualised with
{\tt xv} utility and transformed into {\tt postscript} format.
\item{\sf GRID\#s} to display the grid indices instead of latitude, longitude and
vertical units along the edges of the box.
\item{\sf CONT\#s, LEGENDS} to toggle on or off the isoline values, the colorbar
legends.
\item{\sf BOX, CLOCK} to toggle on or off the display of the box and the clock.
\item{\sf TOP, SOUTH, WEST} to set a top (or bottom), a south (or north), a west
(or east) view.
{\it Select} {\sf SOUTH} {\it to visualise 2D file.}
\item{\sf SAVE, RESTORE, SCRIPT} to save and restore isolines, colors, labels,
view (write and read a Tcl script).
\item{\sf UVW VARS} to specify the names of the variables to use to display wind
slices and trajectories, several triplets of variables can be used.
\item{\sf NEW VAR..} to duplicate variables or create new ones by specifying
mathematical expressions (formulas use names of existing variables, numbers,
arithmetic operations, functions such as $SQRT,EXP,LOG,SIN,COS,TAN,ABS,MIN,MAX$,
ex: horizontal wind speed, $spd=SQRT(UM*UM+VM*VM)$
see section 6.13 of README.ps).
\item{\sf ANIMATE} when several time steps: left mouse button: forward,
right button: backward, S key: slower, F key: faster.
\item{\sf STEP} when several time steps: left mouse button: one step ahead,
middle button: first step, right button: one step back.
\item{\sf DISPLAY} to change the number of displays, the display options
(see section \ref{ss:opt}), the display parameters (as with the {\tt v5dedit}
utility).
\end{itemize}
\underline{\bf Viewing modes} \label{sss:viewing}(section 6.4 of README.ps) \\
The underlined modes are the most useful (the others are much better displayed
with {\tt diaprog} Meso-NH graphics).
\begin{itemize}
\item\underline{\sf Normal}
to rotate, zoom and translate the graphics in the 3D window.
%\item{\sf Trajectory}
% to create and display wind trajectories.
%
\item\underline{\sf Slice}
to reposition horizontal and vertical slices.
\item\underline{\sf Label}
to create and edit text labels in the 3D window.
\item{\sf Probe}
to inspect individual grid values with a cursor moving through the 3D grid.
\item{\sf Sounding}
to display a vertical sounding at the location of the moveable cursor.
\item{\sf Clipping}
to reposition the six bounding planes of the 3-D box. Select one plane (top, bottom,
north, south, west or east) with the middle mouse button, and reposition it
with the right mouse button.
\end{itemize}
\underline{\bf Types of graphic representations} \label{sss:graph}(sections 6.5 to 6.9 of README.ps) \\
The underlined types are the most useful (the others are much better displayed
with {\tt diaprog} Meso-NH graphics).
\begin{itemize}
\item\underline{\sf Isosurfaces}:
A 3-D contour surface showing the volume bounding by a particular value of the
field (set with the left mouse button). The isosurface is either monocolor
or colored according to the values of another variable (right mouse button).
\item\underline{\sf Slices}:
Planar cross section (horizontally or vertically) can be moved in this mode.
To replace geographic coordinates by grid
coordinates, press the {\sf "GRID \#s"} button on the control panel.
\subitem contour line: interval can be changed
and min/max values specified in the pop-up window. {\tt -10 (-30,20)} will
plot values between -30 and 20 at intervals 10 with negative values dashed.
Color can be changed with the right mouse button.
\subitem colored slice: colors can be changed in the pop-up window
(with the mouse buttons or arrow keys). Color table is displayed in the
3-D window if the {\sf "LEGEND \#s"} button is selected.
%Transparency can be changed by pressing the SHIFT key while using mouse.
To change limits of plotted values, use the keyboard array buttons when in
the variable control panel (left and right for limits in the extend of the
variable values, up and down for colors inside it).
\subitem wind vector slice: (buttons {\sf Hwind1, Vwind1, Hwind2, Vwind2})
the scale parameter multiplies the length of vectors drawn
(double: 2, half: 0.5), the density parameter controls the number of vectors
(between zero and one, 0.5 for one vector of two, 0.25 for one of four).
\subitem wind stream slice: (buttons {\sf HStream, VStream})
the density parameter controls the number of streamlines
(between zero and two).
\item\underline{\sf Volume rendering}: {\it for powerful workstations..}
\end{itemize}
\subsubsection{Advanced use}
\begin{itemize}
\item generate your own topography file, with the {\tt maketopo.c} program
in the {\tt util} directory (see 5 of README.ps).
\item Tcl language, to write script (button {\sf SCRIPT}) or
interactively (button {\sf INTERP..}) (see 6.16 of README.ps).
\item external analysis functions written in Fortran,
in {\tt userfuncs} directory (see 6.13.3 of README.ps).
\end{itemize}
\subsection{State of art}
The converter only runs on Linux and VPP.
In HP, right compilation options have to be found to use the external library...
\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:
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 11 7 602 838
%%Title: outils_dia
%%CreationDate: Thu Mar 3 16:51:45 2005
%%Creator: Tgif-4.1.43-QPL written by William Chia-Wei Cheng (bill.cheng@acm.org)
%%ProducedBy: (unknown)
%%Pages: 1
%%DocumentFonts: (atend)
%%EndComments
%%BeginProlog
/tgifdict 53 dict def
tgifdict begin
/tgifarrowtipdict 8 dict def
tgifarrowtipdict /mtrx matrix put
/TGAT % tgifarrowtip
{ tgifarrowtipdict begin
/dy exch def
/dx exch def
/h exch def
/w exch def
/y exch def
/x exch def
/savematrix mtrx currentmatrix def
x y translate
dy dx atan rotate
0 0 moveto
w neg h lineto
w neg h neg lineto
savematrix setmatrix
end
} def
/TGMAX
{ exch dup 3 1 roll exch dup 3 1 roll gt { pop } { exch pop } ifelse
} def
/TGMIN
{ exch dup 3 1 roll exch dup 3 1 roll lt { pop } { exch pop } ifelse
} def
/TGSW { stringwidth pop } def
/bd { bind def } bind def
/GS { gsave } bd
/GR { grestore } bd
/NP { newpath } bd
/CP { closepath } bd
/CHP { charpath } bd
/CT { curveto } bd
/L { lineto } bd
/RL { rlineto } bd
/M { moveto } bd
/RM { rmoveto } bd
/S { stroke } bd
/F { fill } bd
/TR { translate } bd
/RO { rotate } bd
/SC { scale } bd
/MU { mul } bd
/DI { div } bd
/DU { dup } bd
/NE { neg } bd
/AD { add } bd
/SU { sub } bd
/PO { pop } bd
/EX { exch } bd
/CO { concat } bd
/CL { clip } bd
/EC { eoclip } bd
/EF { eofill } bd
/IM { image } bd
/IMM { imagemask } bd
/ARY { array } bd
/SG { setgray } bd
/RG { setrgbcolor } bd
/SD { setdash } bd
/W { setlinewidth } bd
/SM { setmiterlimit } bd
/SLC { setlinecap } bd
/SLJ { setlinejoin } bd
/SH { show } bd
/FF { findfont } bd
/MS { makefont setfont } bd
/AR { arcto 4 {pop} repeat } bd
/CURP { currentpoint } bd
/FLAT { flattenpath strokepath clip newpath } bd
/TGSM { tgiforigctm setmatrix } def
/TGRM { savematrix setmatrix } def
end
%%EndProlog
%%Page: 1 1
%%PageBoundingBox: 11 7 602 838
tgifdict begin
/tgifsavedpage save def
1 SM
1 W
0 SG
90 RO
72 0 MU 72 0 MU TR
72 128 DI 100.000 MU 100 DI DU NE SC
GS
/tgiforigctm matrix currentmatrix def
% TEXT
NP
0 SG
GS
1 W
224 392 M
GS
0 SG
/Helvetica FF [25 0 0 -25 0 0] MS
(readvar) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
472 392 M
GS
0 SG
/Helvetica FF [25 0 0 -25 0 0] MS
(writevar) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
680 392 M
GS
0 SG
/Helvetica FF [25 0 0 -25 0 0] MS
(writecdl) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
880 392 M
GS
0 SG
/Helvetica FF [25 0 0 -25 0 0] MS
(writellhv) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
1120 392 M
GS
0 SG
/Helvetica FF [25 0 0 -25 0 0] MS
(write Fortran) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
224 168 M
GS
0 SG
/Helvetica FF [25 0 0 -25 0 0] MS
(diachronic file) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
456 168 M
GS
0 SG
/Helvetica FF [25 0 0 -25 0 0] MS
(diachronic file) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
664 168 M
GS
0 SG
/Helvetica FF [25 0 0 -25 0 0] MS
(netcdf file) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
864 168 M
GS
0 SG
/Helvetica FF [25 0 0 -25 0 0] MS
(ASCII file) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
1136 168 M
GS
0 SG
/Helvetica FF [25 0 0 -25 0 0] MS
(ASCII file) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
16 132 M
GS
0 SG
/Helvetica FF [25 0 0 -25 0 0] MS
(ASCII file) SH
GR
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
256 184 M
176 0 atan DU cos 12.000 MU 256 exch SU
exch sin 12.000 MU 360 exch SU L
TGSM
3 W
S
1 W
GR
GS
TGSM
NP
256 360 12.000 5.000 0 176 TGAT
1 SG CP F
0 SG
NP
256 360 12.000 5.000 0 176 TGAT
CP F
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
520 184 M
176 0 atan DU cos 12.000 MU exch sin 12.000 MU RM
520 360 L
TGSM
3 W
S
1 W
GR
GS
TGSM
NP
520 184 12.000 5.000 0 -176 TGAT
1 SG CP F
0 SG
NP
520 184 12.000 5.000 0 -176 TGAT
CP F
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
728 184 M
176 0 atan DU cos 12.000 MU exch sin 12.000 MU RM
728 360 L
TGSM
3 W
S
1 W
GR
GS
TGSM
NP
728 184 12.000 5.000 0 -176 TGAT
1 SG CP F
0 SG
NP
728 184 12.000 5.000 0 -176 TGAT
CP F
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
928 184 M
176 0 atan DU cos 12.000 MU exch sin 12.000 MU RM
928 360 L
TGSM
3 W
S
1 W
GR
GS
TGSM
NP
928 184 12.000 5.000 0 -176 TGAT
1 SG CP F
0 SG
NP
928 184 12.000 5.000 0 -176 TGAT
CP F
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
1200 184 M
176 0 atan DU cos 12.000 MU exch sin 12.000 MU RM
1200 360 L
TGSM
3 W
S
1 W
GR
GS
TGSM
NP
1200 184 12.000 5.000 0 -176 TGAT
1 SG CP F
0 SG
NP
1200 184 12.000 5.000 0 -176 TGAT
CP F
GR
% POLY/OPEN-SPLINE
0.000 0.000 1.000 RG
GS
NP
256 456 M
96 0 atan DU cos 12.000 MU 256 exch SU
exch sin 12.000 MU 552 exch SU L
TGSM
3 W
S
1 W
GR
GS
TGSM
NP
256 552 12.000 5.000 0 96 TGAT
1 SG CP F
0.000 0.000 1.000 RG
NP
256 552 12.000 5.000 0 96 TGAT
CP F
GR
% POLY/OPEN-SPLINE
0.000 0.000 1.000 RG
GS
NP
520 456 M
96 0 atan DU cos 12.000 MU exch sin 12.000 MU RM
520 552 L
TGSM
3 W
S
1 W
GR
GS
TGSM
NP
520 456 12.000 5.000 0 -96 TGAT
1 SG CP F
0.000 0.000 1.000 RG
NP
520 456 12.000 5.000 0 -96 TGAT
CP F
GR
% POLY/OPEN-SPLINE
0.000 0.000 1.000 RG
GS
NP
728 456 M
96 0 atan DU cos 12.000 MU exch sin 12.000 MU RM
728 552 L
TGSM
3 W
S
1 W
GR
GS
TGSM
NP
728 456 12.000 5.000 0 -96 TGAT
1 SG CP F
0.000 0.000 1.000 RG
NP
728 456 12.000 5.000 0 -96 TGAT
CP F
GR
% POLY/OPEN-SPLINE
0.000 0.000 1.000 RG
GS
NP
936 456 M
96 0 atan DU cos 12.000 MU exch sin 12.000 MU RM
936 552 L
TGSM
3 W
S
1 W
GR
GS
TGSM
NP
936 456 12.000 5.000 0 -96 TGAT
1 SG CP F
0.000 0.000 1.000 RG
NP
936 456 12.000 5.000 0 -96 TGAT
CP F
GR
% POLY/OPEN-SPLINE
0.000 0.000 1.000 RG
GS
NP
1200 456 M
96 0 atan DU cos 12.000 MU exch sin 12.000 MU RM
1200 552 L
TGSM
3 W
S
1 W
GR
GS
TGSM
NP
1200 456 12.000 5.000 0 -96 TGAT
1 SG CP F
0.000 0.000 1.000 RG
NP
1200 456 12.000 5.000 0 -96 TGAT
CP F
GR
% POLY/OPEN-SPLINE
0.000 0.000 1.000 RG
GS
NP
256 552 M
1336 552 L
TGSM
3 W
S
1 W
GR
% TEXT
NP
0 SG
GS
1 W
352 584 M
GS
0.000 0.000 1.000 RG
/Helvetica FF [25 0 0 -25 0 0] MS
(extractdia) SH
GR
GR
% POLY/OPEN-SPLINE
0.000 1.000 0.000 RG
GS
NP
256 632 M
96 0 atan DU cos 12.000 MU 256 exch SU
exch sin 12.000 MU 728 exch SU L
TGSM
3 W
S
1 W
GR
GS
TGSM
NP
256 728 12.000 5.000 0 96 TGAT
1 SG CP F
0.000 1.000 0.000 RG
NP
256 728 12.000 5.000 0 96 TGAT
CP F
GR
% POLY/OPEN-SPLINE
0.000 1.000 0.000 RG
GS
NP
944 632 M
96 0 atan DU cos 12.000 MU exch sin 12.000 MU RM
944 728 L
TGSM
3 W
S
1 W
GR
GS
TGSM
NP
944 632 12.000 5.000 0 -96 TGAT
1 SG CP F
0.000 1.000 0.000 RG
NP
944 632 12.000 5.000 0 -96 TGAT
CP F
GR
% POLY/OPEN-SPLINE
0.000 1.000 0.000 RG
GS
NP
64 728 M
944 728 L
TGSM
3 W
S
1 W
GR
% TEXT
NP
0 SG
GS
1 W
352 760 M
GS
0.000 1.000 0.000 RG
/Helvetica FF [25 0 0 -25 0 0] MS
(mesonh2obs) SH
GR
GR
% POLY/OPEN-SPLINE
1.000 0.000 1.000 RG
GS
[8 8] 0 SD
NP
240 880 M
96 0 atan DU cos 12.000 MU 240 exch SU
exch sin 12.000 MU 976 exch SU L
TGSM
3 W
S
[] 0 SD
1 W
GR
GS
TGSM
NP
240 976 12.000 5.000 0 96 TGAT
1 SG CP F
1.000 0.000 1.000 RG
NP
240 976 12.000 5.000 0 96 TGAT
CP F
GR
% POLY/OPEN-SPLINE
1.000 0.000 1.000 RG
GS
[8 8] 0 SD
NP
528 880 M
96 0 atan DU cos 12.000 MU exch sin 12.000 MU RM
528 976 L
TGSM
3 W
S
[] 0 SD
1 W
GR
GS
TGSM
NP
528 880 12.000 5.000 0 -96 TGAT
1 SG CP F
1.000 0.000 1.000 RG
NP
528 880 12.000 5.000 0 -96 TGAT
CP F
GR
% POLY/OPEN-SPLINE
1.000 0.000 1.000 RG
GS
[8 8] 0 SD
NP
784 880 M
96 0 atan DU cos 12.000 MU exch sin 12.000 MU RM
784 976 L
TGSM
3 W
S
[] 0 SD
1 W
GR
GS
TGSM
NP
784 880 12.000 5.000 0 -96 TGAT
1 SG CP F
1.000 0.000 1.000 RG
NP
784 880 12.000 5.000 0 -96 TGAT
CP F
GR
% POLY/OPEN-SPLINE
1.000 0.000 1.000 RG
GS
[8 8] 0 SD
NP
1040 880 M
96 0 atan DU cos 12.000 MU exch sin 12.000 MU RM
1040 976 L
TGSM
3 W
S
[] 0 SD
1 W
GR
GS
TGSM
NP
1040 880 12.000 5.000 0 -96 TGAT
1 SG CP F
1.000 0.000 1.000 RG
NP
1040 880 12.000 5.000 0 -96 TGAT
CP F
GR
% POLY/OPEN-SPLINE
1.000 0.000 1.000 RG
GS
[8 8] 0 SD
NP
1296 880 M
96 0 atan DU cos 12.000 MU exch sin 12.000 MU RM
1296 976 L
TGSM
3 W
S
[] 0 SD
1 W
GR
GS
TGSM
NP
1296 880 12.000 5.000 0 -96 TGAT
1 SG CP F
1.000 0.000 1.000 RG
NP
1296 880 12.000 5.000 0 -96 TGAT
CP F
GR
% POLY/OPEN-SPLINE
1.000 0.000 1.000 RG
GS
[8 8] 0 SD
NP
240 976 M
1296 976 L
TGSM
3 W
S
[] 0 SD
1 W
GR
% TEXT
NP
0 SG
GS
1 W
336 1008 M
GS
1.000 0.000 1.000 RG
/Helvetica FF [25 0 0 -25 0 0] MS
(exrwdia ) SH
GR
0 28 RM
GS
1.000 0.000 1.000 RG
/Helvetica FF [20 0 0 -20 0 0] MS
(\( compilation via) SH
GR
0 26 RM
GS
1.000 0.000 1.000 RG
/Helvetica FF [20 0 0 -20 0 0] MS
( make -f $MESONH/MAKE/tools/diachro/Makefile.exrwdia \) ) SH
GR
GR
% POLY/OPEN-SPLINE
1.000 0.000 1.000 RG
GS
[8 8] 0 SD
NP
256 880 M
96 0 atan DU cos 12.000 MU 256 exch SU
exch sin 12.000 MU 976 exch SU L
TGSM
3 W
S
[] 0 SD
1 W
GR
GS
TGSM
NP
256 976 12.000 5.000 0 96 TGAT
1 SG CP F
1.000 0.000 1.000 RG
NP
256 976 12.000 5.000 0 96 TGAT
CP F
GR
% POLY/OPEN-SPLINE
1.000 0.000 1.000 RG
GS
[8 8] 0 SD
NP
272 880 M
96 0 atan DU cos 12.000 MU 272 exch SU
exch sin 12.000 MU 976 exch SU L
TGSM
3 W
S
[] 0 SD
1 W
GR
GS
TGSM
NP
272 976 12.000 5.000 0 96 TGAT
1 SG CP F
1.000 0.000 1.000 RG
NP
272 976 12.000 5.000 0 96 TGAT
CP F
GR
% POLY/OPEN-SPLINE
0.000 1.000 0.000 RG
GS
NP
64 200 M
528 0 atan DU cos 12.000 MU 64 exch SU
exch sin 12.000 MU 728 exch SU L
TGSM
3 W
S
1 W
GR
GS
TGSM
NP
64 728 12.000 5.000 0 528 TGAT
1 SG CP F
0.000 1.000 0.000 RG
NP
64 728 12.000 5.000 0 528 TGAT
CP F
GR
% TEXT
NP
1.000 0.000 1.000 RG
GS
1 W
368 56 M
GS
0 SG
/Helvetica FF [34 0 0 -34 0 0] MS
(Input/Output of extractdia, mesonh2obs, obs2mesonh, exrwdia programs) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
32 164 M
GS
0 SG
/Helvetica FF [18 0 0 -18 0 0] MS
(format=lon,lat) SH
GR
0 22 RM
GS
0 SG
/Helvetica FF [18 0 0 -18 0 0] MS
( lat,lon) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
856 184 M
GS
0 SG
/Helvetica FF [18 0 0 -18 0 0] MS
(format=lon,lat,altitude,value) SH
GR
0 22 RM
GS
0 SG
/Helvetica FF [18 0 0 -18 0 0] MS
( lat,lon,altitude,value) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
1104 184 M
GS
0 SG
/Helvetica FF [18 0 0 -18 0 0] MS
(format=user choice) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
208 424 M
GS
0 SG
/Helvetica FF [20 0 0 -20 0 0] MS
([head ]+ field) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
456 424 M
GS
0 SG
/Helvetica FF [20 0 0 -20 0 0] MS
([head ]+ field) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
688 424 M
GS
0 SG
/Helvetica FF [20 0 0 -20 0 0] MS
(head+ field) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
848 424 M
GS
0 SG
/Helvetica FF [20 0 0 -20 0 0] MS
(3 head lines + x lines data) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
1144 424 M
GS
0 SG
/Helvetica FF [20 0 0 -20 0 0] MS
(x lines data) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
296 544 M
GS
0 SG
/Helvetica FF [20 0 0 -20 0 0] MS
([domain reduced]) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
532 544 M
GS
0 SG
/Helvetica FF [20 0 0 -20 0 0] MS
(if DIAC) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
732 544 M
GS
0 SG
/Helvetica FF [20 0 0 -20 0 0] MS
(if ZCDL/KCDL/PCDL) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
940 544 M
GS
0 SG
/Helvetica FF [20 0 0 -20 0 0] MS
(if LLHV/llhv/LLZV/LLPV) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
1204 544 M
GS
0 SG
/Helvetica FF [20 0 0 -20 0 0] MS
(if FREE) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
920 768 M
GS
0 SG
/Helvetica FF [20 0 0 -20 0 0] MS
([+ vertical interpolation]) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
920 748 M
GS
0 SG
/Helvetica FF [20 0 0 -20 0 0] MS
( horizontal interpolation) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
20 96 M
GS
0 SG
/Helvetica FF [20 0 0 -20 0 0] MS
(export DIROBS=dirname1) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
208 132 M
GS
0 SG
/Helvetica FF [20 0 0 -20 0 0] MS
(export DIRLFI=dirname2) SH
GR
GR
% TEXT
NP
0 SG
NP 695 259 M 768 259 L 768 286 L 695 286 L CP 1 SG F
0 SG
GS
1 W
696 280 M
GS
0 SG
/Helvetica FF [20 0 0 -20 0 0] MS
(tonetcdf) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
852 1004 M
GS
0 SG
/Helvetica FF [20 0 0 -20 0 0] MS
([+ horizontal interpolation \(hor_interp_4pts\)) SH
GR
0 26 RM
GS
0 SG
/Helvetica FF [20 0 0 -20 0 0] MS
( vertical interpolation \(zinter, pinter, zmoy\) ]) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
688 576 M
GS
0 SG
/Helvetica FF [20 0 0 -20 0 0] MS
([+ vertical interpolation on Z-levels or P-levels ]) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
688 596 M
GS
0 SG
/Helvetica FF [20 0 0 -20 0 0] MS
([+ horizontal interpolation on regular lat-lon grid if LALO]) SH
GR
GR
% POLY/OPEN-SPLINE
0.000 0.000 1.000 RG
GS
NP
1336 456 M
96 0 atan DU cos 12.000 MU exch sin 12.000 MU RM
1336 552 L
TGSM
3 W
S
1 W
GR
GS
TGSM
NP
1336 456 12.000 5.000 0 -96 TGAT
1 SG CP F
0.000 0.000 1.000 RG
NP
1336 456 12.000 5.000 0 -96 TGAT
CP F
GR
% TEXT
NP
0 SG
GS
1 W
1340 544 M
GS
0 SG
/Helvetica FF [20 0 0 -20 0 0] MS
(if GRIB) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
1288 392 M
GS
0 SG
/Helvetica FF [25 0 0 -25 0 0] MS
(writegrib) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
1288 168 M
GS
0 SG
/Helvetica FF [25 0 0 -25 0 0] MS
(GRIB file) SH
GR
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
1336 184 M
176 0 atan DU cos 12.000 MU exch sin 12.000 MU RM
1336 360 L
TGSM
3 W
S
1 W
GR
GS
TGSM
NP
1336 184 12.000 5.000 0 -176 TGAT
1 SG CP F
0 SG
NP
1336 184 12.000 5.000 0 -176 TGAT
CP F
GR
% TEXT
NP
0 SG
GS
1 W
1272 424 M
GS
0 SG
/Helvetica FF [20 0 0 -20 0 0] MS
(field \(4 sections\)) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
688 616 M
GS
0 SG
/Helvetica FF [20 0 0 -20 0 0] MS
([+ computation of dd,ff]) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
688 636 M
GS
0 SG
/Helvetica FF [20 0 0 -20 0 0] MS
([+ Uzonal,Vmerid if LALO]) SH
GR
GR
% POLY/OPEN-SPLINE
1.000 0.000 0.000 RG
GS
NP
40 192 M
648 0 atan DU cos 12.000 MU 40 exch SU
exch sin 12.000 MU 840 exch SU L
TGSM
3 W
S
1 W
GR
GS
TGSM
NP
40 840 12.000 5.000 0 648 TGAT
1 SG CP F
1.000 0.000 0.000 RG
NP
40 840 12.000 5.000 0 648 TGAT
CP F
GR
% POLY/OPEN-SPLINE
1.000 0.000 0.000 RG
GS
NP
256 744 M
96 0 atan DU cos 12.000 MU 256 exch SU
exch sin 12.000 MU 840 exch SU L
TGSM
3 W
S
1 W
GR
GS
TGSM
NP
256 840 12.000 5.000 0 96 TGAT
1 SG CP F
1.000 0.000 0.000 RG
NP
256 840 12.000 5.000 0 96 TGAT
CP F
GR
% POLY/OPEN-SPLINE
1.000 0.000 0.000 RG
GS
NP
40 840 M
528 840 L
TGSM
3 W
S
1 W
GR
% POLY/OPEN-SPLINE
1.000 0.000 0.000 RG
GS
NP
528 744 M
96 0 atan DU cos 12.000 MU exch sin 12.000 MU RM
528 840 L
TGSM
3 W
S
1 W
GR
GS
TGSM
NP
528 744 12.000 5.000 0 -96 TGAT
1 SG CP F
1.000 0.000 0.000 RG
NP
528 744 12.000 5.000 0 -96 TGAT
CP F
GR
% TEXT
NP
0 SG
GS
1 W
296 864 M
GS
1.000 0.000 0.000 RG
/Helvetica FF [25 0 0 -25 0 0] MS
(obs2mesonh) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
456 860 M
GS
0 SG
/Helvetica FF [20 0 0 -20 0 0] MS
([+ Uzonal,Vmerid ->UM,VM]) SH
GR
GR
GR
tgifsavedpage restore
end
showpage
%%Trailer
%MatchingCreationDate: Thu Mar 3 16:51:45 2005
%%DocumentFonts: Helvetica
%%EOF
\documentclass[12pt]{article}
\usepackage[latin1]{inputenc}
\usepackage{epsfig}
\setlength{\textwidth}{16.cm}
\setlength{\textheight}{24.cm}
%\oddsidemargin=+1.6cm
%\evensidemargin=+0.6cm
\voffset=-1.8cm
\hoffset=-1.cm
%\makeindex
\begin{document}
%%%%%%%%%% Definition of new commands for LATEX :
%
\newcommand{\ignore}[1]{}
%
%
\title {Tools related to Meso-NH model}
\author{N. Asencio, J. Duron, J. Escobar, D. Gazen, P. Jabouille, I. Mallet}
\date{\today}
\maketitle
\tableofcontents
\include{intro}
\include{lfiz}
\include{conv2dia}
\include{lfi2cdf}
\include{extract}
\include{lfi2grb}
\end{document}
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 3 397 592 827
%%Title: toolstab
%%CreationDate: Wed Mar 2 10:14:19 2005
%%Creator: Tgif-4.1.43-QPL written by William Chia-Wei Cheng (bill.cheng@acm.org)
%%ProducedBy: (unknown)
%%Pages: 1
%%DocumentFonts: (atend)
%%EndComments
%%BeginProlog
/tgifdict 56 dict def
tgifdict begin
/tgifarrowtipdict 8 dict def
tgifarrowtipdict /mtrx matrix put
/TGAT % tgifarrowtip
{ tgifarrowtipdict begin
/dy exch def
/dx exch def
/h exch def
/w exch def
/y exch def
/x exch def
/savematrix mtrx currentmatrix def
x y translate
dy dx atan rotate
0 0 moveto
w neg h lineto
w neg h neg lineto
savematrix setmatrix
end
} def
/tgifarcdict 8 dict def
tgifarcdict /mtrx matrix put
/TGAN % tgifarcn
{ tgifarcdict begin
/endangle exch def
/startangle exch def
/yrad exch def
/xrad exch def
/y exch def
/x exch def
/savematrix mtrx currentmatrix def
x y translate
xrad yrad scale
0 0 1 startangle endangle arc
savematrix setmatrix
end
} def
/TGAR % tgifarc
{ tgifarcdict begin
/endangle exch def
/startangle exch def
/yrad exch def
/xrad exch def
/y exch def
/x exch def
/savematrix mtrx currentmatrix def
x y translate
xrad yrad scale
0 0 1 startangle endangle arcn
savematrix setmatrix
end
} def
/TGMAX
{ exch dup 3 1 roll exch dup 3 1 roll gt { pop } { exch pop } ifelse
} def
/TGMIN
{ exch dup 3 1 roll exch dup 3 1 roll lt { pop } { exch pop } ifelse
} def
/TGSW { stringwidth pop } def
/bd { bind def } bind def
/GS { gsave } bd
/GR { grestore } bd
/NP { newpath } bd
/CP { closepath } bd
/CHP { charpath } bd
/CT { curveto } bd
/L { lineto } bd
/RL { rlineto } bd
/M { moveto } bd
/RM { rmoveto } bd
/S { stroke } bd
/F { fill } bd
/TR { translate } bd
/RO { rotate } bd
/SC { scale } bd
/MU { mul } bd
/DI { div } bd
/DU { dup } bd
/NE { neg } bd
/AD { add } bd
/SU { sub } bd
/PO { pop } bd
/EX { exch } bd
/CO { concat } bd
/CL { clip } bd
/EC { eoclip } bd
/EF { eofill } bd
/IM { image } bd
/IMM { imagemask } bd
/ARY { array } bd
/SG { setgray } bd
/RG { setrgbcolor } bd
/SD { setdash } bd
/W { setlinewidth } bd
/SM { setmiterlimit } bd
/SLC { setlinecap } bd
/SLJ { setlinejoin } bd
/SH { show } bd
/FF { findfont } bd
/MS { makefont setfont } bd
/AR { arcto 4 {pop} repeat } bd
/CURP { currentpoint } bd
/FLAT { flattenpath strokepath clip newpath } bd
/TGSM { tgiforigctm setmatrix } def
/TGRM { savematrix setmatrix } def
end
%%EndProlog
%%Page: 1 1
%%PageBoundingBox: 3 397 592 827
tgifdict begin
/tgifsavedpage save def
1 SM
1 W
0 SG
72 0 MU 72 11.695 MU TR
72 128 DI 100.000 MU 100 DI DU NE SC
GS
/tgiforigctm matrix currentmatrix def
% POLY/OPEN-SPLINE
0 SG
GS
NP
40 40 M
168 104 L
TGSM
1 W
S
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
168 32 M
168 784 L
TGSM
3 W
S
1 W
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
12 104 M
840 104 L
TGSM
3 W
S
1 W
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
424 32 M
424 784 L
TGSM
1 W
S
GR
% TEXT
NP
0 SG
GS
1 W
104 56 M
GS
0 SG
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(IN) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
56 88 M
GS
0 SG
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(OUT) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
232 56 M
GS
0 SG
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(synchronous FM file) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
496 56 M
GS
0 SG
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(diachronic FM file) SH
GR
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
296 72 M
296 232 L
TGSM
1 W
S
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
552 72 M
552 232 L
TGSM
1 W
S
GR
% TEXT
NP
0 SG
GS
1 W
172 88 M
GS
0 SG
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(Uncompressed) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
312 88 M
GS
0 SG
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(Compressed) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
56 152 M
GS
GS
0
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
(synchro-) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
(synchro-) SH
GR
0 25 RM
GS
GS
0
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
(nuous ) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
(nuous ) SH
GR
0 25 RM
GS
GS
0
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
(FM file) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
(FM file) SH
GR
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
104 168 M
840 168 L
TGSM
2 W
S
1 W
GR
% TEXT
NP
0 SG
GS
1 W
104 144 M
GS
0 SG
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(Uncomp.) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
56 288 M
GS
GS
0
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
(diachronic) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
(diachronic) SH
GR
0 25 RM
GS
GS
0
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
(FM file) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
(FM file) SH
GR
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
12 232 M
840 232 L
TGSM
2 W
S
1 W
GR
% TEXT
NP
0 SG
GS
1 W
432 88 M
GS
0 SG
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(Uncompressed) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
576 88 M
GS
0 SG
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(Compressed) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
104 208 M
GS
0 SG
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(Comp.) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
68 268 M
GS
0 SG
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(Uncomp.) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
72 328 M
GS
0 SG
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(Comp.) SH
GR
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
104 296 M
840 296 L
TGSM
2 W
S
1 W
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
12 360 M
840 360 L
TGSM
2 W
S
1 W
GR
% TEXT
NP
0 SG
GS
1 W
360 136 M
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(unlfiz) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(unlfiz) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
224 208 M
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(lfiz) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(lfiz) SH
GR
GR
% ARC
0 SG
GS
GS
NP
92 92 45 45 -105 -131 TGAR
2 W
S
GR
GR
GS
TGSM
NP
57 64 10.000 4.000 -55 71 TGAT
1 SG CP F
0 SG
NP
57 64 10.000 4.000 -55 71 TGAT
CP F
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
168 104 M
296 168 L
TGSM
2 W
S
1 W
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
168 168 M
296 104 L
TGSM
2 W
S
1 W
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
424 104 M
680 232 L
TGSM
2 W
S
1 W
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
424 232 M
680 104 L
TGSM
2 W
S
1 W
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
296 168 M
424 232 L
TGSM
2 W
S
1 W
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
296 232 M
424 168 L
TGSM
2 W
S
1 W
GR
% TEXT
NP
0 SG
GS
1 W
296 252 M
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(conv2dia) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(conv2dia) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
476 316 M
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(lfiz) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(lfiz) SH
GR
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
12 424 M
680 424 L
TGSM
2 W
S
1 W
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
12 488 M
680 488 L
TGSM
2 W
S
1 W
GR
% TEXT
NP
0 SG
GS
1 W
624 280 M
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(extractdia) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(extractdia) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
64 392 M
GS
GS
0
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
(GRIB) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
(GRIB) SH
GR
0 25 RM
GS
GS
0
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
( file) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
( file) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
248 392 M
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(lfi2grb) TGSW
AD
GR
2 DI NE 0 RM
0.000 0.000 1.000 RG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(lfi2grb) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
64 456 M
GS
GS
0
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
(Vis5D) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
(Vis5D) SH
GR
0 25 RM
GS
GS
0
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
( file) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
( file) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
248 456 M
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(lfi2v5d) TGSW
AD
GR
2 DI NE 0 RM
0.000 0.000 1.000 RG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(lfi2v5d) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
68 516 M
GS
GS
0
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
(NetCDF) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
(NetCDF) SH
GR
0 25 RM
GS
GS
0
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
( file) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
( file) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
232 512 M
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(lfi2cdf) TGSW
AD
GR
2 DI NE 0 RM
0.000 0.000 1.000 RG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(lfi2cdf) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
488 512 M
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(lfi2cdf) TGSW
AD
GR
2 DI NE 0 RM
0.000 0.000 1.000 RG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(lfi2cdf) SH
GR
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
12 552 M
680 552 L
TGSM
2 W
S
1 W
GR
% TEXT
NP
0 SG
GS
1 W
64 584 M
GS
GS
0
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
(ASCII) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
(ASCII) SH
GR
0 25 RM
GS
GS
0
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
( file) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
( file) SH
GR
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
12 616 M
680 616 L
TGSM
2 W
S
1 W
GR
% TEXT
NP
0 SG
GS
1 W
76 648 M
GS
GS
0
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
(NCAR-CGM) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
(NCAR-CGM) SH
GR
0 25 RM
GS
GS
0
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
( file) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/NewCenturySchlbk-Bold FF [17 0 0 -17 0 0] MS
( file) SH
GR
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
168 616 M
424 680 L
TGSM
2 W
S
1 W
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
168 680 M
424 616 L
TGSM
2 W
S
1 W
GR
% TEXT
NP
0 SG
GS
1 W
552 656 M
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(diaprog) TGSW
AD
GR
2 DI NE 0 RM
0.373 0.620 0.627 RG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(diaprog) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
552 572 M
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(diaprog ) TGSW
AD
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(->FICVAL) TGSW
AD
GR
2 DI NE 0 RM
0.373 0.620 0.627 RG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(diaprog ) SH
0 SG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(->FICVAL) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
552 592 M
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(extractdia) TGSW
AD
GR
2 DI NE 0 RM
0.000 0.000 1.000 RG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(extractdia) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
488 536 M
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(extractdia) TGSW
AD
GR
2 DI NE 0 RM
0.000 0.000 1.000 RG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(extractdia) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
296 320 M
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(conv2dia+lfiz) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(conv2dia+lfiz) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
624 536 M
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(extractdia) TGSW
AD
GR
2 DI NE 0 RM
0.000 0.000 1.000 RG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(extractdia) SH
GR
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
552 488 M
552 552 L
TGSM
1 W
S
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
296 488 M
296 552 L
TGSM
1 W
S
GR
% TEXT
NP
0 SG
GS
1 W
616 252 M
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(unlfiz) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(unlfiz) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
492 348 M
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(extractdia+lfiz) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(extractdia+lfiz) SH
GR
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
12 680 M
680 680 L
TGSM
2 W
S
1 W
GR
% TEXT
NP
0 SG
GS
1 W
560 696 M
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(exrwdia \(readvar, writevar,) TGSW
AD
GR
2 DI NE 0 RM
0.000 0.000 1.000 RG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(exrwdia \(readvar, writevar,) SH
GR
0 23 RM
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(zinter,pinter,lalo\)) TGSW
AD
GR
2 DI NE 0 RM
0.000 0.000 1.000 RG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(zinter,pinter,lalo\)) SH
GR
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
168 736 M
168 784 L
TGSM
1 W
S
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
424 736 M
424 784 L
TGSM
1 W
S
GR
% TEXT
NP
0 SG
GS
1 W
96 744 M
GS
GS
0
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(ex: diachronic file) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(ex: diachronic file) SH
GR
0 23 RM
GS
GS
0
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(\(Lag. var.\)) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(\(Lag. var.\)) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
292 760 M
GS
GS
0
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(DIAG with) TGSW
AD
/Helvetica-Bold FF [14 0 0 -14 0 0] MS
( LTRAJ =TRUE) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(DIAG with) SH
0 SG
/Helvetica-Bold FF [14 0 0 -14 0 0] MS
( LTRAJ =TRUE) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
560 752 M
GS
GS
0
/Helvetica-Bold FF [14 0 0 -14 0 0] MS
(compute_r00_pc ) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Helvetica-Bold FF [14 0 0 -14 0 0] MS
(compute_r00_pc ) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
552 608 M
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(mesonh2obs) TGSW
AD
GR
2 DI NE 0 RM
0.000 0.000 1.000 RG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(mesonh2obs) SH
GR
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
840 32 M
840 360 L
TGSM
3 W
S
1 W
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
680 32 M
840 32 L
TGSM
3 W
S
1 W
GR
% TEXT
NP
0 SG
GS
1 W
720 72 M
GS
0 SG
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(ASCII file) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
760 136 M
GS
GS
0
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(PREP_PGD) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(PREP_PGD) SH
GR
0 23 RM
GS
GS
0
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(\() TGSW
AD
/Helvetica-Bold FF [14 0 0 -14 0 0] MS
(&NAM_DUMMY_PGD) TGSW
AD
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(\)) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(\() SH
0 SG
/Helvetica-Bold FF [14 0 0 -14 0 0] MS
(&NAM_DUMMY_PGD) SH
0 SG
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(\)) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
760 192 M
GS
GS
0
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(PREP_PGD) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(PREP_PGD) SH
GR
0 19 RM
GS
GS
0
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(+) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(+) SH
GR
0 19 RM
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(lfiz) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(lfiz) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
344 392 M
GS
GS
0
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(CONVLFI) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(CONVLFI) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
344 456 M
GS
GS
0
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(CONVLFI) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(CONVLFI) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
96 704 M
GS
GS
0
/NewCenturySchlbk-Roman FF [14 0 0 -14 0 0] MS
(other treatments,) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/NewCenturySchlbk-Roman FF [14 0 0 -14 0 0] MS
(other treatments,) SH
GR
0 17 RM
GS
GS
0
/NewCenturySchlbk-Roman FF [14 0 0 -14 0 0] MS
(other formats) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/NewCenturySchlbk-Roman FF [14 0 0 -14 0 0] MS
(other formats) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
352 512 M
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(unlfiz+) TGSW
AD
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(lfi2cdf) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(unlfiz+) SH
0.000 0.000 1.000 RG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(lfi2cdf) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
624 512 M
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(unlfiz+) TGSW
AD
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(lfi2cdf) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(unlfiz+) SH
0.000 0.000 1.000 RG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(lfi2cdf) SH
GR
GR
% POLY/OPEN-SPLINE
0.000 0.000 1.000 RG
GS
NP
224 396 M
272 396 L
TGSM
1 W
S
GR
% POLY/OPEN-SPLINE
0.000 0.000 1.000 RG
GS
NP
224 460 M
276 460 L
TGSM
1 W
S
GR
% POLY/OPEN-SPLINE
0.000 0.000 1.000 RG
GS
NP
208 516 M
256 516 L
TGSM
1 W
S
GR
% POLY/OPEN-SPLINE
0.000 0.000 1.000 RG
GS
NP
356 516 M
404 516 L
TGSM
1 W
S
GR
% POLY/OPEN-SPLINE
0.000 0.000 1.000 RG
GS
NP
452 540 M
524 540 L
TGSM
1 W
S
GR
% POLY/OPEN-SPLINE
0.000 0.000 1.000 RG
GS
NP
464 516 M
508 516 L
TGSM
1 W
S
GR
% POLY/OPEN-SPLINE
0.000 0.000 1.000 RG
GS
NP
628 516 M
672 516 L
TGSM
1 W
S
GR
% POLY/OPEN-SPLINE
0.000 0.000 1.000 RG
GS
NP
588 540 M
656 540 L
TGSM
1 W
S
GR
% POLY/OPEN-SPLINE
0.000 0.000 1.000 RG
GS
NP
516 596 M
584 596 L
TGSM
1 W
S
GR
% POLY/OPEN-SPLINE
0.000 0.000 1.000 RG
GS
NP
504 612 M
600 612 L
TGSM
1 W
S
GR
% POLY/OPEN-SPLINE
0.000 0.000 1.000 RG
GS
NP
460 700 M
516 700 L
TGSM
1 W
S
GR
% TEXT
NP
0 SG
GS
1 W
764 272 M
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(obs2mesonh) TGSW
AD
GR
2 DI NE 0 RM
0.000 0.000 1.000 RG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(obs2mesonh) SH
GR
GR
% POLY/OPEN-SPLINE
0.000 0.000 1.000 RG
GS
NP
716 276 M
812 276 L
TGSM
1 W
S
GR
% TEXT
NP
0 SG
GS
1 W
764 316 M
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(obs2mesonh) TGSW
AD
GR
2 DI NE 0 RM
0.000 0.000 1.000 RG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(obs2mesonh) SH
GR
GR
% POLY/OPEN-SPLINE
0.000 0.000 1.000 RG
GS
NP
716 320 M
812 320 L
TGSM
1 W
S
GR
% TEXT
NP
0 SG
GS
1 W
764 336 M
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(+) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(+) SH
GR
0 19 RM
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(lfiz) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(lfiz) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
688 428 M
GS
0 SG
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(MAINPROG) SH
0 SG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
( : ) SH
0 SG
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
(main program of MesoNH ) SH
GR
0 23 RM
GS
0 SG
/NewCenturySchlbk-Roman FF [17 0 0 -17 0 0] MS
( \(run it on supc with prepmodel\)) SH
GR
0 23 RM
GS
0 SG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(tool : one of the libtools package ) SH
GR
0 23 RM
GS
0 SG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
( \(run it interactively on local host\)) SH
GR
0 23 RM
GS
0 SG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
( \() SH
0.000 0.000 1.000 RG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(tool) SH
0 SG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
( with change of file format\)) SH
GR
GR
% POLY/OPEN-SPLINE
0.000 0.000 1.000 RG
GS
NP
744 512 M
768 512 L
TGSM
1 W
S
GR
% TEXT
NP
0 SG
GS
1 W
492 280 M
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(extractdia) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(extractdia) SH
GR
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
552 232 M
552 296 L
TGSM
1 W
S
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
552 296 M
552 360 L
TGSM
1 W
S
GR
% TEXT
NP
0 SG
GS
1 W
624 348 M
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(extractdia) TGSW
AD
GR
2 DI NE 0 RM
0 SG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(extractdia) SH
GR
GR
% POLY/OPEN-SPLINE
0.000 0.000 1.000 RG
GS
NP
712 524 M
740 524 L
TGSM
1 W
S
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
140 520 M
680 520 L
TGSM
1 W
S
GR
% TEXT
NP
0 SG
GS
1 W
104 544 M
GS
0 SG
/NewCenturySchlbk-Roman FF [14 0 0 -14 0 0] MS
(var. list) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
112 508 M
GS
0 SG
/NewCenturySchlbk-Roman FF [14 0 0 -14 0 0] MS
(all var.) SH
GR
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
140 324 M
680 324 L
TGSM
1 W
S
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
140 260 M
680 260 L
TGSM
1 W
S
GR
% TEXT
NP
0 SG
GS
1 W
108 252 M
GS
0 SG
/NewCenturySchlbk-Roman FF [14 0 0 -14 0 0] MS
(all var.) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
108 316 M
GS
0 SG
/NewCenturySchlbk-Roman FF [14 0 0 -14 0 0] MS
(all var.) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
104 288 M
GS
0 SG
/NewCenturySchlbk-Roman FF [14 0 0 -14 0 0] MS
(var. list) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
100 352 M
GS
0 SG
/NewCenturySchlbk-Roman FF [14 0 0 -14 0 0] MS
(var. list) SH
GR
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
168 260 M
420 292 L
TGSM
2 W
S
1 W
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
168 292 M
420 260 L
TGSM
2 W
S
1 W
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
172 324 M
424 356 L
TGSM
2 W
S
1 W
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
172 356 M
424 324 L
TGSM
2 W
S
1 W
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
168 552 M
424 616 L
TGSM
2 W
S
1 W
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
168 616 M
424 552 L
TGSM
2 W
S
1 W
GR
% TEXT
NP
0 SG
GS
1 W
548 396 M
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(extractdia in future) TGSW
AD
GR
2 DI NE 0 RM
0.000 0.000 1.000 RG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(extractdia in future) SH
GR
GR
% TEXT
NP
0 SG
GS
1 W
548 456 M
GS
GS
0
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(extractdia in future) TGSW
AD
GR
2 DI NE 0 RM
0.000 0.000 1.000 RG
/Helvetica-Bold FF [17 0 0 -17 0 0] MS
(extractdia in future) SH
GR
GR
% POLY/OPEN-SPLINE
0.000 0.000 1.000 RG
GS
NP
472 400 M
544 400 L
TGSM
1 W
S
GR
% POLY/OPEN-SPLINE
0.000 0.000 1.000 RG
GS
NP
476 460 M
548 460 L
TGSM
1 W
S
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
12 28 M
12 788 L
TGSM
3 W
S
1 W
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
680 32 M
12 32 L
TGSM
3 W
S
1 W
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
12 784 M
684 784 L
TGSM
3 W
S
1 W
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
684 360 M
684 784 L
TGSM
3 W
S
1 W
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
684 32 M
684 364 L
TGSM
1 W
S
GR
% POLY/OPEN-SPLINE
0 SG
GS
NP
684 360 M
840 360 L
TGSM
3 W
S
1 W
GR
GR
tgifsavedpage restore
end
showpage
%%Trailer
%MatchingCreationDate: Wed Mar 2 10:14:19 2005
%%DocumentFonts: Helvetica-Bold
%%+ NewCenturySchlbk-Bold
%%+ NewCenturySchlbk-Roman
%%EOF
#
#compute_r00_pc
#==============
# Version PC de la routine compute_r00 utilisee dans le programme DIAG
#(voir la doc. "Lagrangian trajectory and air-mass tracking analyses with
#MesoNH by means of Eulerian passive tracers", Gheusi and Stein, 2003)
# On garde la structure F90 et la routine d'interpolation (interpxyz) mais on
#utilise les routines de lecture/ecriture de fichiers diachroniques
#(READVAR et WRITEVAR)
#
# il faut disposer
# 1)des fichiers diachroniques contenant les champs Lagrangiens LGXM,LGYM,LGZM
#(conversion par conv2dia de fichiers synchrones issus d une simulation avec LLG=T)
# 2)d'un fichier de namelist nommé compute_r00.nam, contenant le nom des
# fichiers diachroniques et eventuellement une liste de champs supplementaires
# devant etre concatenes, ex:
cat<<'eof' >compute_r00.nam
&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',
NSTART_SUP(1)=3 /
&NAM_FIELD CFIELD_LAG(1)='THM',
CFIELD_LAG(2)='RVM' /
eof
#
# initialiser
export DIRLFI=directory_fichier_diachro # facultatif si les fichiers sont dans le repertoire courant
# initialiser la variable ARCH (LXNAGf95 sur PC, HPf90 sur HP)
export ARCH=LXNAGf95
# executer
$MESONH/MAKE/tools/diachro/$ARCH/compute_r00_pc
#
# Les champs (X000,Y000,Z000,THM00,RVM00) sont concatenes depuis l instant
#initial (celui du dernier fichier de NAM_STO_FILE, CFILES(5) dans l exemple)
#jusqu'a l'instant du fichier traite (tous sauf le dernier de NAM_STO_FILE).
#Dans l exemple ci-dessus, une deuxieme serie de champs
#(X001,Y001,Z001,THM01,RVM01) sont concatenes depuis l'instant du fichier
#repere par NSTART_SUP(1) (CFILES(3) dans l exemple).
#Ces champs supplementaires sont ajoutes a ceux du fichier traite.
#Les possibilites de trace sont elargies puisque champs Lagrangiens concatenes
#et champs synchrones sont dans le meme fichier.
#
#
#personnalisation :
#=================
# cf $MESONH/MAKE/tools/diachro/exrwdia.LISEZMOI
#
# Pour modifier le programme:
#
# *initialiser et exporter la variable MNH_LIBTOOLS
#
export MNH_LIBTOOLS=$MESONH/MAKE
#
# *dans votre repertoire de travail:
# copier le fichier Makefile.exrwdia de $MNH_LIBTOOLS/tools/diachro
#
cp $MNH_LIBTOOLS/tools/diachro/Makefile.exrwdia Makefile
#
# *creer un repertoire qui contiendra les fichiers sources nommé src
# puis y copier exrwdia.f90, le modifier eventuellement
#
mkdir src
cp $MNH_LIBTOOLS/tools/diachro/src/EXTRACTDIA/compute_r00_pc.f90 src/.
#
# compiler par
#
gmake PROG=compute_r00_pc
#
# *completer le Makefile (liste des objets dans OBJS et dependances)
# si vous ajoutez des routines (exemple dans
# $MESONH/MAKE/tools/diachro/Makefile.extractdia)
#
# Mise à jour le 30/04/2004
&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' /
# exrwdia
# =======
#outil (version simplifiee de extractdia) qui permet:
# 1)d'extraire des champs 2D/3D d'un fichier diachronique (sortie conv2dia)
# 2)d'extraire un zoom i,j,k,t,traj,process du champ
# 3)d'effectuer des calculs sur le champ extrait
# (ex: maximum sur la verticale, moyenne verticale entre 2 niveaux,
# interpolation verticale et horizontale, autre code perso)
# 4)d'ecrire ce zoom extrait au format:
# 'DIAC'= nouveau fichier diachronique visualisable par diaprog
# 'LLHV'= fichier ascii lon,lat,altitude,valeur
# 'llhv'= fichier ascii lat,lon,altitude,valeur
# 'FREE'= format libre à fixer au programme
# 'KCDL'= format CDL ( passage au format netcdf via
# le script Unix tonetcdf appelé par le programme)
#
#
# Pour les autres formats possibles LLZV LLPV llzv llpv ZCDL ou PCDL,
# 'CONF' grille régulière sur le plan conforme,'LALO' grille régulière
# en lat-lon , un conseil: sortir en format 'DIAC' puis utiliser extractdia
# et activer les choix LLZV LLPV llzv llpv ZCDL PCDL , CONF ou LALO
#
# Cet outil nécessite une connaissance de l'utilisation des différentes
# grilles de Mesonh (voir le book3).
#
#personnalisation :
#=================
# Le programme extractdia est base sur 2 routines de lecture (READVAR)
# et d'écriture (WRITEVAR) de champs Mesonh qui peuvent être utilisées
# dans un programme utilisateur pour traiter des fichiers diachroniques.
#
#- Un exemple de programme (exrwdia.f90) est disponible sous le repertoire
# $MESONH/MAKE/tools/diachro/src/EXTRACTDIA
#
# Pour modifier le programme exrwdia (ou un autre programme personnel):
# 1)initialiser et exporter la variable ARCH
#(LXpgf90 ou LXNAGf95 sur PC Linux 32bits, HPf90 sur HP)
#
export ARCH=LXNAGf95
#
# 2)creer un repertoire nomme src qui contiendra les fichiers sources
# puis y copier exrwdia.f90 et eventuellement vos propres routines
#
mkdir src
cp $MESONH/MAKE/tools/diachro/src/EXTRACTDIA/exrwdia.f90 src/my_prog.f90
#
# 3)dans votre repertoire de travail:
# compiler par
#
gmaketools PROG=my_prog OBJS="my_routine1.o my_routine2.o"
#
# 3bis)OU initialiser et exporter la variable MNH_LIBTOOLS
#
export MNH_LIBTOOLS=$MESONH/MAKE
#
# copier le fichier Makefile.exrwdia de $MNH_LIBTOOLS/tools/diachro
#
cp $MNH_LIBTOOLS/tools/diachro/Makefile.exrwdia Makefile
#
# completer le Makefile si vous avez des routines supplementaires
#(liste des objets dans OBJS et dependances) :
# exemple dans $MESONH/MAKE/tools/diachro/Makefile.extractdia
#
# compiler par
#
gmake
# 4) l executable est dans le repertoire $ARCH
#
#- D autres exemples de programmes bases sur READVAR et WRITEVAR sont
#extractdia.f90
#mesonh2obs.f90
#obs2mesonh.f90
#compute_r00_pc.f90
#dans $MESONH/MAKE/tools/diachro/src/EXTRACTDIA
#
#execution :
#===========
# initialiser (facultatif si le fichier est dans le repertoire courant)
export DIRLFI=directory_fichier_diachro
# et executer
exrwdia
#
#
#
#Scripts utilisés donc accessibles depuis votre environnement:
#===========================================================
#rmlink, tonetcdf
#
#
# Mise à jour le 30/01/2004
# Mise à jour le 01/03/2005
#
#extractdia
#==========
#outil qui permet:
# 1)d'extraire des champs 2D/3D d'un fichier diachronique (sortie conv2dia)
# 2)d'extraire un zoom i,j,k,t,traj,process du champ
# 3)de calculer dd(direction 0-360),ff(intensité)
# 3)d'ecrire ce zoom extrait au format:
# 'DIAC'= nouveau fichier diachronique visualisable par diaprog
# 'LLHV'= fichier ascii lon,lat,altitude_niveaux_modèle,valeur
# 'llhv'= fichier ascii lat,lon,altitude_niveaux_modèle,valeur
# 'LLZV'= fichier ascii lon,lat,altitude_niveaux_Z=cst,valeur
# 'llzv'= fichier ascii lat,lon,altitude_niveaux_Z=cst,valeur
# 'LLPV'= fichier ascii lon,lat,altitude_niveaux_P=cst,valeur
# 'llpv'= fichier ascii lat,lon,altitude_niveaux_P=cst,valeur
# 'FREE'= format libre à fixer au programme
# 'KCDL' ou 'ZCDL' ou 'PCDL'= format CDL ( passage au format netcdf via
# le script Unix tonetcdf appelé par le programme)
# KCDL = fichier cdl avec les niveaux verticaux du modèle
# ZCDL = fichier cdl avec des interpolations sur des
# niveaux Z=constante donnés en input à extractdia
# PCDL = fichier cdl avec des interpolations sur des
# niveaux P=constante donnés en input à extractdia
# pour le format *CDL,*Z*,*P* 2 types de grilles horizontales sont
# possibles 'CONF' grille régulière sur le plan conforme
# 'LALO' grille régulière en lat-lon
# dans ce cas les composantes du vent seront transformées
# en composantes zonales et méridiennes.
#
# initialiser (facultatif si le fichier est dans le repertoire courant)
export DIRLFI=directory_fichier_diachro
# (les liens crees seront supprimes a la fin du programme par l appel a rmlink
# present dans bin)
# *executer (procedure de $MESONH)
extractdia # et répondre aux questions
# Un fichier "dirextract" consignera toutes vos réponses
# rentrées au clavier
# ou
extractdia < dirextract_créé_execution_précédente
#
# pour acceder directement au binaire:
# *initialiser et exporter la variable ARCH
#(LXpgf90 ou LXNAGf95 sur PC Linux, HPf90 sur HP)
export ARCH=LXpgf90
# *initialiser et exporter la variable MNH_LIBTOOLS
export MNH_LIBTOOLS=$MESONH/MAKE
# *executer
${MNH_LIBTOOLS}/tools/diachro/$ARCH/extractdia
#
#Scripts utilisés donc accessibles depuis votre environnement
#===========================================================
#rmlink, tonetcdf
#(presents dans ${MNH_LIBTOOLS}/bin)
#
#
# Mise à jour le 30/01/2004
# Mise à jour le 01/03/2005
#! /bin/sh
FILE=${1:-Bret45.99082200dg.Z}
#DIRLFI=${2:-.}
export DIRLFI
#
ARCH=LXNAGf95
B=32
#
rm ${FILE}*zc*
/mesonh/MAKE/tools/diachro/${ARCH}_${B}/extractdia << EOF
$FILE
ZCDL
5
1,10,1,10
1,1,1,1,1,1
3
1500 3000 5000
LALO
LAT
ALT
LON
END
EOF
#! /bin/sh
FILE=${1:-16J36.1.00A12.001dg.Z}
DIRLFI=${2:-DATA}
export DIRLFI
#
ARCH=LXNAGf95
B=32
#
rm $(basename $FILE .Z)2.lfi
/mesonh/MAKE/tools/diachro/${ARCH}_${B}/extractdia << EOF
$FILE
DIAC
1
30,50,20,40,0,0
1,1,1,1
FF
THM
DD
ALT
END
EOF