source: CPL/oasis3-mct/branches/OASIS3-MCT_2.0_branch/doc/anaisgb.tex @ 4775

Last change on this file since 4775 was 4775, checked in by aclsce, 4 years ago
  • Imported oasis3-mct from Cerfacs svn server (not suppotred anymore).

The version has been extracted from https://oasis3mct.cerfacs.fr/svn/branches/OASIS3-MCT_2.0_branch/oasis3-mct@1818

  • Property svn:executable set to *
File size: 19.4 KB
Line 
1 \magnification =\magstep1
2\count0=90
3%definitions
4
5%end of definitions
6
7
8\centerline{ Olivier Thual, June 30$^{\rm th}$ 1992}
9 \bigskip
10
11\centerline{\bf SIMPLE OCEAN-ATMOSPHERE INTERPOLATION.} 
12\centerline{\bf PART B: SOFTWARE IMPLEMENATION}
13
14
15\bigskip
16
17
18A set of FORTRAN subroutines constitutes an implementation the ``naive''
19grid-to-grid interpolation method which has been exposed in the previous
20Part A of this letter. This implementation  is tested  for  both idealized,
21EMERAUDE or OPA  grids, masks and scalar fields.  These
22subroutines can  be used in the first version the ocean-atmosphere coupler.
23
24
25
26
27
28\beginsection 1. INTRODUCTION
29
30Coupling two atmospheric and  oceanic general circulation models (AGCM
31and OGCM) having two different grids and sea-land masks, requires the
32interpolation of fluxes from the atmosphere to the ocean grids and of the
33sea surface temperature (SST) in the reverse direction.  A simple method
34to perform these interpolations have been presented in the previous Epicoa
35Letter [1]  called ``Simple ocean-atmosphere interpolation. Part A: the method'' as a
36particular case of a more general class of interpolations based on
37optimization theory (Lagrangian formalism).   
38
39\medskip
40
41The name  of ``naive method'' which has been given to denote one of the simplest
42interpolation among this class,  comes from the motivations
43which have governed its implementation. It was designed with simplicity
44requirement and short deadlines in order to reach as quickly as possible a
45first version of an ocean-atmosphere coupler. A more ``sovarphisticated
46method'' is beeing studied in parallel by Norman BARTH [2]. This method
47imposes the conservation of the field integral on each mesh of the coarser
48grid, and requires, in order to satisfy these multiple constraints, the
49mutiplication by matrices of the coarser grid size square for each
50interpolation.
51
52A lot of the concepts which are used in the ``naive method'', comes from
53the ones that are considered in the ``sovarphisticated method'' [3,2], but retain
54only the low cost ones. The coupler will offer the possibility of choosing
55between the ``naive'' or ``sovarphisticated'' methods, depending on various
56constraints (memory space, computer time, efficiency, accuracy, etc...).
57Other methods, like the one of Philippe DANDIN [4], will also be pluged into
58the coupler.
59
60
61
62
63
64\medskip
65
66
67
68
69
70The ``naive method'' can be summarized in few words:  knowing the values
71of a field on a source grid, the values on a point of the target grid is
72calculated by summing the values if its $L$th closest neighbors, with a
73weight which quicky decreases with the interdistance.
74
75
76
77\medskip
78
79In Section 2, I recall the definition of the ``naive method'' in a concise
80way. In Section 3, I briefly
81describe the ``naive method library'', which is  the set of FORTRAN
82subroutines that I have written to implement the method, and focus on the
83visible part of the  iceberg that the coupler will need to know.  Some basic
84tests of this method are presented,  showing that there is no trivial bug
85left.   
86
87
88
89
90
91
92
93
94
95\beginsection 2.  THE NAIVE METHOD
96
97In Part A of this letter [1] general considerations about  grid-to-grid
98interpolation have been presented, and a ``simple  ocean-atmosphere  method'' have be
99presented in this general framework. Here I only present the materials
100necessary to its implementation.
101
102
103
104\beginsection 2.1 Interpolation without constraints (SST)
105
106Let $(b_j), j=1,N^b$ be the SST (sea surface temperature) on the ocean grid
107B,  defined by the points $(r^b_j), j=1,N^b$. Only the umasked points are
108considered in this definition of the grids and the following formula.  The
109values $(a_i), i=1,N^a$ of the SST on the atmospheric grid A,   defined by
110the points $(r^a_i), i=1,N^a$, are  given, in the naive method, by:
111$$
112a_i={1\over Z^b( r^a_i)} \sum_{m\in J(r_i^a)} b_i \;
113\phi\left( {\left| r_j^b-r_i^a\right| \over \sigma_b } \right) 
114\eqno(2.1)\; ,
115$$
116where $J(r)=\{j_1(r),  j_2(r), ..., j_{L^b}(r)\}$ is the set containing the
117indices of the $L^b$ closest neighbors $r_m^b$ in grid B, of a point $r$
118located anywhere, and the normalizing function $Z^b$, defined for all  grids
119points of the gird A is:
120$$
121 Z^b( r^a_i)= \sum_{m\in J(r_i^a)
122\phi\left( {\left| r_j^b-r_i^a\right| \over \sigma_b } \right)  \; .
123\eqno(2.2)
124$$
125
126
127
128In its present implementation the weight function $\phi$ is a gaussian:
129$$
130\phi(u) = e^{-u^2 \over 2}
131\eqno(2.3) \;.
132$$
133
134The variance $ \sigma_b$ is of the order one or two times the average
135mesh size  of the grid B.  Other choices of the weight functions are
136discussed below.
137
138
139
140
141
142
143
144
145
146
147
148\beginsection 2.2 Summary of the Lagrangian formalism
149
150As explained in Part A [1], the extension of the above grid-to-grid
151interpolation to an interpolation with constraints can be defined through a
152formalism in which a Lagrangian functionnal is to be minimized under
153these constraints.
154
155
156
157In this formalism, both the source grid A (on which $N^a$ values $a_i$ are
158known) and the target grid B (on which $N^b$ values $b_i$ are to be found)
159are associated to an interpolation which reads:
160
161$$
162f(r)= \sum_{i=1}^{N^a} a_i \varphi_i(r) 
163\eqno(2.4)
164$$
165for grid  A, which is made of $N^a$ grid points,  and
166$$
167g(r)= \sum_{j=1}^{N^b} b_j \psi_j(r) 
168\eqno(2.5)
169$$
170for grid  B, which is made of $N^b$ grid points.
171
172
173
174If we impose that the equality of the integrals of the two functions $f$
175and $g$ (fluxes) on the two respective domains that the two grids are
176covering,  a constrained interpolation method is defined by the
177minimization of the Lagrangian:
178$$
179L(b_1,b_2,...,b_{N^b}) = \int [f(r)-g(r)]^2  \; dr + 
180\lambda \int [f(r)-g(r)] \; dr 
181\eqno(2.6)
182$$
183subject to the constraints $ \int [f(r)-g(r)] \; dr =0$.
184
185With the matrix notations  $B=(b_j)$, $A=(a_i)$, $H=(\int \psi_j dr)$, $G=(\int
186\varphi_i dr)$ and $V=(\int \psi_m \psi_j dr)$, where $i=1,N^a$ and $j$
187or $m=1,N^b$, the solution of the minimization of $L$, subject to the
188constraint $HB=GA$, is given by $B=B^*-\lambda
189V^{-1}H$, where  $B^*= V^{-1}UA$ is the solution without constraint and
190$\lambda$,  the Lagragian multiplicator,  is given by
191$$
192\lambda= { HB^*-GA \over HV^{-1}H}
193\eqno(2.7) \;.
194$$
195
196
197
198The solution with constraints reads, in its final form
199$$
200\eqalign{
201B=& B^* -{ HB^* - GA \over HV^{-1}H }  V^{-1}H \cr
202=& V^{-1}UA- {HV^{-1}UA - GA\over HV^{-1}H} V^{-1}H }
203\eqno(2.8) \;.
204$$
205(NB: this expression
206and Equation 2.6 gives the errata of Equations 4.4, 4.6 and 4.7 of the first
207version {\bf 0615}  of the  Part A
208of this letter, now revised [1]).
209
210\beginsection 2.3 Interpolation with one constraint (Flux)
211
212The easiest implementation of the above interpolation with constraint is
213obtained when $V$ is the unity matrix, that is when the interpolation
214associated with the target grid is the ``closest neighbor'' interpolation
215(see Part A [1] for details).
216
217
218
219The above naive method, combined with this global conservation constraint
220of the integrals over the two domains (total fluxes) read:
221
222$$
223b_j=b^*_j - \lambda  h_j 
224\eqno(2.9)
225$$
226where the unconstrained solution is
227$$
228b^*_j={1\over Z^a( r^b_j)} \sum_{m\in I(r_j^b)} a_i
229\phi\left( {\left| r_i^a-r_j^b\right| \over \sigma_a } \right) 
230\eqno(2.10)\; ,
231$$ 
232and the Lagrangian multiplier is given by
233$$
234\lambda =  {\sum_{j=1}^{N^b} h_j b^*_j -   \sum_{i=1}^{N^a} g_i a^*_i
235\over  \sum_{j=1}^{N^b} h_j h_j  }
236\eqno(2.11) 
237$$
238where $I(r)=\{i_1(r),  i_2(r), ..., i_{L^b}(r)\}$ is the set containing the indices
239of the $L^a$ closest neighbors $r_m^a$ in grid A, of a point $r$ located
240anywhere, and the normalizing function $Z^a$, defined for all  grids points
241of the gird B is:
242$$
243 Z^a( r^b_j)= \sum_{m\in I(r_j^b)
244\phi\left( {\left| r_i^a-r_j^b\right| \over \sigma_a } \right)  \; .
245\eqno(2.12)
246$$
247
248
249
250In the above expressions, $h_j$ is the area of the grid B meshes (see Part
251A [1]) and
252$$
253g_i= \int  {1\over Z^a( r)} \phi\left( {\left|r- r_i^a\right| \over \sigma_a
254}\right)\; dr
255\eqno(2.12)
256$$ 
257
258In the present implementation of the software, these coefficients have been
259approximated by the surface of the meshes, i.e., $g_i$ is
260 the surface of the set of all the points which admit $r_i^a$ as their
261 closest neighbor.   This is as if the closest neighbor
262interpolation were chosen in the constraint, while another  interpolation is
263chosen in the quadratic term of the Lagrangain.
264 However, in the future evolution of the
265software, more elabored values of $g_i$ will be possible.
266
267 
268
269
270
271\vfill\eject
272
273
274
275
276
277
278
279
280
281\beginsection 3. IMPLEMENTATION OF THE METHOD
282
283The above method have been implemented through a set of FORTRAN subroutines
284which constitutes the  ``naive method library''. Some practical details
285are given in view of its use in the  coupler, or for testing purposes.
286 A first set of basic tests
287is shown, and the future evolution of this library is hinted.
288
289
290
291\beginsection 3.1 The ``naive method library''
292
293The directory
294 {\tt greenh@cerfacs.fr:/usr1/pub/numlab/naiv} contains a software
295environment and a set of subroutines constituting the current
296implementation of the ``naive'' grid-to-grid interpolation method.  These
297FORTRAN subroutines have been written following the DOCTOR norm [5, 6].
298A main program performs various tests of these subroutines, and give
299examples of the use of theses subroutines. 
300
301
302
303\bigskip
304
305
306
307The initialization of the grids, the masks and the fields is dependant of the
308atmospheric and oceanic GCMs to be coupled, and will communicated by
309them to the coupler independantly of the interpolation task. However, the
310present library also contains subroutines which generates academic grids,
311masks or fields for testing purposes, and, so far, the initialization of a
312128x64 EMERAUDE grid, a 228x94 OPA-Pacific grid and some EMERAUDE
313fluxes. Extension to other realistic grids for testing purposes are planned.
314
315
316\beginsection 3.2 A first draft for a manual
317
318 This library is written is such a way that  only a few items
319need to be visible from the coupler. The names of these subroutines
320start with {\tt NA}. These high level subroutines call basic subroutines
321with, most of the time,
322a name starting with  {\tt PL}.
323A very preliminary draft is given through the name of these
324subroutines.
325
326
327\medskip
328\medskip
329\noindent{\bf Include files} 
330 \medskip
331
332These are, at first, three include files containing the commons which
333describe the grids:
334
335
336
337\medskip
338
339\item{}{\tt NAGRA.H}, containing the common for the arrays of grid A (e.g.
340atmsopheric).
341
342
343
344\medskip
345
346\item{}{\tt NAGRB.H}, containing the common for the arrays grid B (e.g.
347ocean).
348
349
350
351\medskip
352
353\item{}{\tt NAGAB.H}, containing the commons for the weight arrays used
354in  the grid-to-grid interpolations.
355
356
357
358\medskip
359\medskip
360\noindent{\bf Grid initializations subroutines} 
361 \medskip
362
363The two first sets of commons of {\tt NAGRA.H} and {\tt NABRB.H}, for grid
364A and grid B, can be initialized by the subroutines:
365
366
367
368\medskip
369
370\item{} {\tt NAGRDA },  to initialize idealized  A grids.
371
372
373
374\medskip
375
376\item{} {\tt NAGRDB },  to initialize idealized  B grids.
377
378
379
380\medskip
381
382\item{} {\tt NAGMRO },  to initialize the A grid from the EMERAUDE
383128x64 global grid.
384
385
386
387\medskip
388
389\item{} {\tt NAGOPA},  to initialize idealized  B grid from the OPA
390226x94 Pacific grid.
391
392
393
394
395\medskip
396\medskip
397\noindent{\bf Interpolations subroutines} 
398 \medskip
399
400The last set of common, in {\tt NAGAB.H} are calculated in the subourtine:
401
402\medskip
403
404\item{} {\tt NASET(amesh,bmesh)},
405 to initialize the weight arrays of the  interpolation, given the variances
406of the weight functions {\tt amesh} and  {\tt amesh}.   
407
408
409\medskip
410
411
412
413Once the three initialisations are done, the grid A to grid B, and  grid  B to
414grid A interpolations are  performed by the two subroutines:
415
416
417
418\medskip
419
420
421
422\item{} {\tt NASST(ssta,sstb)}, to interpolate a field from grid B to
423grid A without constraint
424(e.g. the SST).
425
426\medskip
427
428\item{} {\tt NAFLUX(fluxb,fluxa)}, to interpolate a field from grid A to
429grid B while conserving
430its average between the two unmasked domains (e.g., fluxes).
431
432\medskip
433\medskip
434\noindent{\bf Basic subroutines} 
435 \medskip
436
437These suboutines are called by the higher level subroutines, and need not to
438be known by the first time user:
439
440
441{\tt
442PLDIS2.f  PLGPRI.f  PLGRDU.f  PLQQT.f   PLSCAR.f  PLSST.f   PLVISU.f
443
444
445PLFLUX.f  PLGRDC.f  PLINS.f   PLRHAL.f  PLSORT.f  PLSTAT.f
446
447
448PLGAUS.f  PLGRDP.f  PLMASQ.f  PLRHO.f   PLSSPH.f  PLTMRO.f
449
450
451IMPR.f   IMPRI.f
452}
453
454\medskip
455\medskip
456\noindent{\bf Testing  subroutines} 
457 \medskip
458
459
460Examples of the use of these ``coupler-visible'' subroutines (with names
461starting by {\tt NA}), or of the ``basic'' subroutines (with names starting by PL)
462can be found in several test performing subroutines:
463
464\medskip
465
466\item{} {\tt NATFX(fluxb,fluxa)}:
467 call {\tt NAFLUX} and visualizes the fields.
468
469\medskip
470
471\item{} {\tt NATST(ssta,sstb)}: call {\tt NASST} and visualizes the fields.
472
473\medskip
474
475\item{} {\tt NATES1(flda,fldb,fldaa)}: calls
476{\tt NASST} and then {\tt NAFLUX}, visualizes the fields, and compares the
477intial and final fields. 
478
479\medskip
480
481\item{} {\tt NATES2(flda,fldb,fldaa)}:  calls
482  {\tt NAFLUX} and then {\tt NASST}, and compares the
483intial and final fields.
484\medskip
485
486\item{} {\tt NATES3(flda,fldb,fldaa,kvisuo}: calls 
487  {\tt NAFLUX} and  then {\tt NASST} and visualizes the fields in a way that
488allows animations.
489Typically, the influence of the variance of the weight functions can be
490studied with this subroutine, through animation of the error field.
491
492\medskip
493\medskip
494
495These testing subroutines  assume
496that the grids and the interpolation coefficients have already been
497initialized.
498
499
500
501\beginsection 3.3 Tests of the grid-to-grid interpolation
502
503Various tests have been performed to check that the library of subroutines of
504was free of trivial tests. However, systematic tests of the performance of
505the ``naive method'' and its sensibility to its adjustable parameters (shape
506and variance of the weight functions, number of neighbours, relative
507positions of the masks, ...) still remain to be done.
508
509
510
511\medskip
512
513In the following tests, the weight function $\phi$
514 is a Gaussian, with a uniform
515variance on a given grid.
516
517\medskip
518
519
520
521The most trivial test was to check that with a one neighbour interpolation,
522and the same grid, the interpolation was giving the same field. 
523
524
525
526\medskip
527
528
529
530The second test has been made with an analytically generated field $f(x,y)=$
531$\cos (k1 x)$ $\cos(k_2 y)$ interpolation  forward (NAFLUX) an backward
532(NASST) between a cartesian square grid and a polar disk grid, with
533non-coincident masks.  Figure show an example in which
534 small neighbour number has been given
535to the naive method. This test shows that the original field is well
536recovered, excepted, of course, in the regions where the mask are far from
537coincidence.
538
539\medskip
540
541
542
543
544
545The third test  uses two grids of very different resolutions, with a mask
546defined by an analytical curve.  The case of a circle  is shown on Figure 2,
547and more complex contour should be used in future tests of this kind.
548
549\medskip
550
551
552
553
554
555The fourth test (Figure 3) studies the interpolation between an
556analytically defined field $f(x,y)$ on the masked EMERAUDE grid
557(Atmospheric GCM) and the unmasked Pacific OPA (Ocean GCM).   In the
558forward interpolation (NAFLUX), the trace of the EMERAUDE mask can be
559seen on the unmasked OPA domain. In the backward direction (NASST), the
560original field is well recovered  on the tropical Pacific, and, of course,
561meaninless far from this region.
562
563
564
565The last test  (Figure 4) deals with a realistic flux field (stress $\tau_ x$
566in the longitudinal direction) of EMERAUDE and shows it interpolation on
567the Pacific OPA masked grid. Comparison with Philippe Dandin's
568interpolation's method is under progress.                       
569
570
571
572\beginsection 3.4 Future developments
573
574In the  present state of the ``naive method library'',
575 the coupler-visible items  are
576ready  to be used in the coupler. However, they are at the
577stage of a $\beta$-release, and will be improved by furthers tunings.  The
578possibility of choosing weight functions which shape and variance can vary
579with the index of the grid point will be given. This will allow, for instance,
580to use ``non-smoothing'' function, e.g. the  functions associated to the
581spectral method used on the grid [7]. This will also allow   to pay special
582attention to land-sea regions, or  implement interpolation method based on
583``wavelet decomposition''. 
584
585
586
587%The calculation of the grid surface elements is not yet  properly
588%implemented for spherical grids.
589
590
591
592\beginsection 4. CONCLUSION
593
594The present letter can be considered as a first draft of a user manual of
595the ``naive method''. A concise presentation
596 of the  method has been presented,
597as well ot its possible future evolution. Pratical details for the
598use of the ``naive method library'' have been given in the spirit of its
599integration into the coupler. The names of testing subroutines which can be
600read as examples have been given.
601
602
603
604Further steps need to be done in order to reach a clean version of this
605``naive method library'', with a more complete user manual. However, these
606first steps in the organisation of a sofware product, with the respect of
607the DOCTOR norm, the separation between  subroutines ``visible''  from a
608calling code, with a minimal list of argument and extensive use of
609commons, and  ``basic'' subroutines free of commons, can be helpfull  for
610the organization of our future software development. Such an organization
611is also found in the ``Spectral Interface Library'' [8].
612
613
614
615\beginsection  Acknowledgments
616
617I thank Dominique ASTRUC for helping to use his visualization software [9]
618with which the Figure have been produced.
619
620
621
622
623\beginsection REFERENCES
624
625
626\def\ref{\parskip 12pt \leftskip 20pt \parindent -20pt} 
627\def\endref{\parskip 0pt \leftskip 0pt \parindent 20pt}
628
629
630\ref
631
632[1]
633O. THUAL, Simple  ocean-atmosphere  interpolation. Part A: the method,
634 {\it Epicoa \ } {\bf 0315}  (1992).
635
636
637
638[2]
639N. H. BARTH,  A Conservative Scheme for Passing Variables Between
640Coupled Models of the Ocean an Atmosphere
641 {\it Technical Report \ }, CERFACS (1992).
642
643
644
645[3]
646O. THUAL, Gathering information for a coupler,
647 {\it Epicoa \ } {\bf 0119} (1992).
648
649
650
651
652[4]
653P. DANDIN, th\`ese de doctorat, in preparation (1992).
654
655
656
657[5] J. CLOCHARD, Norme de codage ``DOCTOR'' pour le projet ARPEGE,{\it Note de
658travail ``AREPEGE''}  {\bf No. 4} (1988).
659
660
661
662[6] J. K. GIBSON, The Doctor system - A DOCumentary ORiented programming
663system, {\it ECMWF Technical Memorandum}  {\bf No. 52} (1982).
664
665
666[7] P. BERNARDET, private communication (1992).
667
668[8]  O. THUAL, Spectral Interfaces Library Version 2.2,  CERFACS (1990).
669
670
671[9]  D. ASTRUC,  Visuo: manuel de l'utilisateur, {\it Internal Report}
672(1990).
673 
674\endref
675
676
677\vfill\eject
678\centerline{ Exchange of Projects and Ideas for Coupling Ocean and
679Atmosphere (Epicoa)}
680\centerline{ Appendix to Olivier Thual(8) , June 30$^{\rm th}$ 1992}
681 \bigskip
682
683
684\centerline{\bf  SOURCE OF THE NAIVE METHOD LIBRARY}
685 \bigskip
686
687\centerline{ Version naiv01,  92 06 30 } 
688
689
690
691\bigskip \bigskip
692
693This version is contained in {\tt
694greenh@cerfacs.fr:/usr1/pub/numlab/naiv/cnaiv01}
695
696\bigskip \bigskip
697
698
699
700\beginsection 1. Include files
701
702{\tt
703
704NAGAB.H  NAGRA.H  NAGRB.H
705
706
707}
708
709\beginsection 2. Main Program
710
711
712
713{\tt
714
715ANAIV.f
716
717}
718
719
720
721\beginsection 3. Coupler visible subroutines {\tt NA - - - -} 
722
723
724
725{\tt
726
727NAFLUX.f  NAGMRO.f  NAGRA.H   NAGRDA.f  NASET.f   NATES1.f  NATES3.f  NATST.f
728
729
730NAGAB.H   NAGOPA.f  NAGRB.H   NAGRDB.f  NASST.f   NATES2.f  NATFX.f
731
732
733
734}
735
736
737
738\beginsection 4. Basic  subroutines {\tt PL - - - -} 
739
740
741
742{\tt
743
744PLDIS2.f  PLGPRI.f  PLGRDU.f  PLQQT.f   PLSCAR.f  PLSST.f   PLVISU.f
745
746
747PLFLUX.f  PLGRDC.f  PLINS.f   PLRHAL.f  PLSORT.f  PLSTAT.f
748
749
750PLGAUS.f  PLGRDP.f  PLMASQ.f  PLRHO.f   PLSSPH.f  PLTMRO.f
751
752
753
754
755}
756
757
758
759\beginsection 5. Subroutine stolen from outside
760
761
762
763{\tt
764
765IMPR.f   IMPRI.f
766
767
768}
769
770
771
772\end
773
774
775
Note: See TracBrowser for help on using the repository browser.