source: CONFIG/LMDZOR/branches/LMDZOR_v4/CREATE/SCRIPT/era2gcm.ksh @ 1366

Last change on this file since 1366 was 1366, checked in by jgipsl, 11 years ago
  • era2gcm.ksh : new simplified version of era2gcm.x
  • interp_from_era.ksh : new version of get_era.x including interpolation and adding next time step.
  • 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' ] ; then
34        varout=vwnd
35        grille='grille_v'
36    elif [ ${varin} = 'ta' ] ; then
37        varout=air
38        grille='grille_t'
39    elif [ ${varin} = 'r' ] ; 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]
65!repeat/l=1:${tmax} save/file="${fileout}"/append ${varout}[d=2,g=${grille}]
66repeat/l=1:2 save/file="${fileout}"/append ${varout}[d=2,g=${grille}]
67
68exit
69eod
70   
71###################################################################
72# 3 - Launch interpolation with ferret
73###################################################################
74    ferret -nojnl <<eod >  /dev/null
75go ${varin}.jnl
76quit
77eod
78
79#}
Note: See TracBrowser for help on using the repository browser.