source: CONFIG/LMDZORINCA/tags/LMDZORINCA_v1/CREATE/SCRIPT/era2gcm.ksh @ 1447

Last change on this file since 1447 was 1447, checked in by acosce, 14 years ago

Add Script directory for CREATE in LMDZORINCA

  • Property svn:executable set to *
File size: 2.4 KB
Line 
1#!/bin/ksh
2#set -xv
3# Function that does a linear interpolation of the variable in
4# filein towards the destionation grid in gridfile. Results in are
5# stored in fileout.
6#
7# Exemple for use :
8# ./era2gcm.ksh grilles_gcm.nc u_filein.nc u_fileout.nc u
9#
10###################################################################
11# O - Input arguments
12###################################################################
13# gridfile : File containing the target grid (grilles_gcm.nc)
14    gridfile=$1
15# filein : File containing the variable at source grid
16    filein=$2
17# fileout : Output file with the variable at target grid
18    fileout=$3
19# varin : Variable name in source file
20    varin=$4
21
22###################################################################
23# 1 - Define variables
24###################################################################
25# Find number of time step
26    tmax=`ncdump -h ${filein} | grep time | head -1 | awk ' { print $6 } '`
27    tmax=$( echo ${tmax} | awk '-F(' '{print $2}' )
28   
29# Choose grid and output variable name
30    if [ ${varin} = 'u' ] || [ ${varin} = 'vitu' ] ; then
31        varout=uwnd
32        grille='grille_u'
33    elif [ ${varin} = 'v' ] || [ ${varin} = 'vitv' ] ; then
34        varout=vwnd
35        grille='grille_v'
36    elif [ ${varin} = 'ta' ] || [ ${varin} = 'temp' ] ; then
37        varout=air
38        grille='grille_t'
39    elif [ ${varin} = 'r' ] || [ ${varin} = 'hur' ] ; then
40        varout=rh
41        grille='grille_t'
42    elif [ ${varin} = 'msl' ] ; then
43        varout=sp
44        grille='grille_t'
45    else
46        echo Error : ${varin} unknown!!!!
47        exit
48    fi 
49
50###################################################################
51# 2 - Create ferret script for interpolation
52###################################################################
53    cat << eod >  ${varin}.jnl
54set memory/size=50
55
56use "${gridfile}"
57use "${filein}"
58let ${varout}=${varin}
59
60define grid/like=${varout}[d=2]/x=grille_u[d=1]/y=grille_u[d=1] grille_u
61define grid/like=${varout}[d=2]/x=grille_v[d=1]/y=grille_v[d=1] grille_v
62define grid/like=${varout}[d=2]/x=grille_v[d=1]/y=grille_u[d=1] grille_t
63
64save/clobber/file="${fileout}" ${varout}[d=2,g=${grille},l=1]
65repeat/l=1:${tmax} save/file="${fileout}"/append ${varout}[d=2,g=${grille}]
66
67exit
68eod
69   
70###################################################################
71# 3 - Launch interpolation with ferret
72###################################################################
73    ferret -nojnl <<eod >  /dev/null
74go ${varin}.jnl
75quit
76eod
77
78#}
Note: See TracBrowser for help on using the repository browser.