New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
opa_tam.F90 in branches/TAM_V3_2_2/NEMOTAM/OPATAM_SRC – NEMO

source: branches/TAM_V3_2_2/NEMOTAM/OPATAM_SRC/opa_tam.F90 @ 3277

Last change on this file since 3277 was 2578, checked in by rblod, 13 years ago

first import of NEMOTAM 3.2.2

File size: 20.4 KB
Line 
1MODULE opa_tam
2#if defined key_tam
3   !!==============================================================================
4   !!                       ***  MODULE opa_tam   ***
5   !! Ocean system   : TAM of the OPA ocean dynamics
6   !!==============================================================================
7   !! History of the direct module:
8   !!            OPA  ! 1990-10  (C. Levy, G. Madec)  Original code
9   !!            7.0  ! 1991-11  (M. Imbard, C. Levy, G. Madec)
10   !!            7.1  ! 1993-03  (M. Imbard, C. Levy, G. Madec, O. Marti, M. Guyon, A. Lazar,
11   !!                             P. Delecluse, C. Perigaud, G. Caniaux, B. Colot, C. Maes )  release 7.1
12   !!             -   ! 1992-06  (L.Terray)  coupling implementation
13   !!             -   ! 1993-11  (M.A. Filiberti) IGLOO sea-ice
14   !!            8.0  ! 1996-03  (M. Imbard, C. Levy, G. Madec, O. Marti, M. Guyon, A. Lazar,
15   !!                             P. Delecluse, L.Terray, M.A. Filiberti, J. Vialar, A.M. Treguier, M. Levy)  release 8.0
16   !!            8.1  ! 1997-06  (M. Imbard, G. Madec)
17   !!            8.2  ! 1999-11  (M. Imbard, H. Goosse)  LIM sea-ice model
18   !!                 ! 1999-12  (V. Thierry, A-M. Treguier, M. Imbard, M-A. Foujols)  OPEN-MP
19   !!                 ! 2000-07  (J-M Molines, M. Imbard)  Open Boundary Conditions  (CLIPPER)
20   !!   NEMO     1.0  ! 2002-08  (G. Madec)  F90: Free form and modules
21   !!             -   ! 2004-06  (R. Redler, NEC CCRLE, Germany) add OASIS[3/4] coupled interfaces
22   !!             -   ! 2004-08  (C. Talandier) New trends organization
23   !!             -   ! 2005-06  (C. Ethe) Add the 1D configuration possibility
24   !!             -   ! 2005-11  (V. Garnier) Surface pressure gradient organization
25   !!             -   ! 2006-03  (L. Debreu, C. Mazauric)  Agrif implementation
26   !!             -   ! 2006-04  (G. Madec, R. Benshila)  Step reorganization
27   !!             -   ! 2007-07  (J. Chanut, A. Sellar) Unstructured open boundaries (BDY)
28   !!            3.2  ! 2009-08  (S. Masson)  open/write in the listing file in mpp
29   !! History of the TAM module:
30   !!            3.0  ! 2009-06  (F. Vigilant) first version (2 different executables)
31   !!            3.2  ! 2011-01  (A. Vidard) Rewriting it as one executable and update to 3.2.2
32   !!----------------------------------------------------------------------
33
34   !!----------------------------------------------------------------------
35   !!   opa_model      : solve ocean dynamics, tracer and/or sea-ice
36   !!   opa_init       : initialization of the opa model
37   !!   opa_flg        : initialisation of algorithm flag
38   !!   opa_closefile  : close remaining files
39   !!----------------------------------------------------------------------
40   USE oce             ! dynamics and tracers variables
41   USE dom_oce         ! ocean space domain variables
42   USE sbc_oce         ! surface boundary condition: ocean
43   USE trdmod_oce      ! ocean variables trends
44   USE domcfg          ! domain configuration               (dom_cfg routine)
45   USE mppini          ! shared/distributed memory setting (mpp_init routine)
46   USE domain          ! domain initialization             (dom_init routine)
47   USE obc_par         ! open boundary cond. parameters
48   USE obcini          ! open boundary cond. initialization (obc_ini routine)
49   USE bdy_par         ! unstructured open boundary cond. parameters
50   USE bdyini          ! unstructured open boundary cond. initialization (bdy_init routine)
51   USE istate          ! initial state setting          (istate_init routine)
52   USE sbcmod          ! surface boundary condition
53   USE eosbn2          ! equation of state                 (eos_init routine)
54   USE dynhpg          ! hydrostatic pressure gradient
55   USE ldfdyn          ! lateral viscosity setting      (ldfdyn_init routine)
56   USE ldftra          ! lateral diffusivity setting    (ldftra_init routine)
57   USE zdfini
58   USE phycst          ! physical constant                  (par_cst routine)
59   USE trdmod          ! momentum/tracers trends       (trd_mod_init routine)
60   USE diaptr          ! poleward transports           (dia_ptr_init routine)
61
62   USE tamtrj          ! writing out state trajectory
63   USE trj_tam         ! reading in state trajectory
64   USE tamtst          ! TAM testing options and init
65   USE step            ! OPA time-stepping                  (stp     routine)
66#if defined key_oasis3
67   USE cpl_oasis3      ! OASIS3 coupling
68#elif defined key_oasis4
69   USE cpl_oasis4      ! OASIS4 coupling (not working)
70#endif
71   USE dynspg_oce      ! Control choice of surface pressure gradient schemes
72   USE prtctl          ! Print control                 (prt_ctl_init routine)
73   USE c1d             ! 1D configuration
74   USE dyncor_c1d      ! Coriolis factor at T-point
75   USE step_c1d        ! Time stepping loop for the 1D configuration
76#if defined key_top
77   USE trcini          ! passive tracer initialisation
78#endif
79   
80   USE iom
81   USE in_out_manager  ! I/O manager
82   USE lib_mpp         ! distributed memory computing
83#if defined key_iomput
84   USE mod_ioclient
85#endif
86
87   USE opatlh           ! Tangent linear hypothesis testing
88   USE tamtst           ! Testing of the TAM operators
89   USE tamctl
90   USE oce_tam          ! OCE TAM field
91   USE sol_oce_tam      ! Initialize elliptic solver
92   USE trc_oce_tam      ! TRC TAM fields
93   USE sbc_oce_tam      ! SBC TAM fields
94   USE sbcmod_tam     
95   
96
97
98   IMPLICIT NONE
99   PRIVATE
100
101   PUBLIC   opa_tam_model   ! called by model_tam.F90
102   PUBLIC   opa_tam_init    ! needed by AGRIF (? for tam ?)
103
104   CHARACTER (len=64) ::   cform_aaa="( /, 'AAAAAAAA', / ) "     ! flag for output listing
105
106   !!----------------------------------------------------------------------
107   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009)
108   !! $Id$
109   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
110   !!----------------------------------------------------------------------
111
112CONTAINS
113
114   SUBROUTINE opa_tam_model
115      !!----------------------------------------------------------------------
116      !!                     ***  ROUTINE opa  ***
117      !!
118      !! ** Purpose :   opa solves the primitive equations on an orthogonal
119      !!              curvilinear mesh on the sphere.
120      !!
121      !! ** Method  : - model general initialization
122      !!              - launch the time-stepping (stp routine)
123      !!              - finalize the run by closing files and communications
124      !!
125      !! References : Madec, Delecluse,Imbard, and Levy, 1997:  internal report, IPSL.
126      !!              Madec, 2008, internal report, IPSL.
127      !!----------------------------------------------------------------------
128      INTEGER ::   istp       ! time step index
129      !!----------------------------------------------------------------------
130
131#if defined key_agrif
132      CALL Agrif_Init_Grids()      ! AGRIF: set the meshes
133#endif
134
135      !                            !-----------------------!
136      CALL opa_tam_init            !==  Initialisations  ==!
137      !                            !-----------------------!
138      PRINT*,'init_done'
139      ! check that all process are still there... If some process have an error,
140      ! they will never enter in step and other processes will wait until the end of the cpu time!
141      IF( lk_mpp )   CALL mpp_max( nstop )
142
143      IF(lwp) WRITE(numout,cform_aaa)   ! Flag AAAAAAA
144
145      !                            !-----------------------!
146      !                            !==   time stepping   ==!
147      !                            !-----------------------!
148      istp = nit000
149      IF ( ln_tst_opatam .AND. ln_tst_tlh .AND. .NOT. ln_incdx ) CALL opa_tlh_store
150
151      nstop = 0
152
153      IF( lk_c1d ) THEN                 !==  1D configuration  ==!
154         CALL ctl_stop( '       lk_c1d not available')         
155      ELSE                              !==  3D ocean with  ==!
156         DO WHILE ( istp <= nitend .AND. nstop == 0 )
157#if defined key_agrif
158            CALL ctl_stop( '       Agrif not available')
159#else
160            CALL stp( istp )                 ! standard time stepping
161#endif
162            istp = istp + 1
163            IF( lk_mpp )   CALL mpp_max( nstop )
164         END DO
165      ENDIF
166      IF ( ln_tst_opatam .AND. nstop == 0 ) THEN
167         IF ( ln_tst_tlh ) THEN
168            CALL opa_tlh
169         END IF
170         IF ( ln_tst_adj_cpd .OR. ln_tst_adj_stp .OR. ln_tst_tan_cpd .OR. ln_tst_tan_stp ) THEN
171            CALL tam_tst
172         END IF
173      END IF
174      !                            !------------------------!
175      !                            !==  finalize the run  ==!
176      !                            !------------------------!
177      IF(lwp) WRITE(numout,cform_aaa)   ! Flag AAAAAAA
178      !
179      IF( nstop /= 0 .AND. lwp ) THEN   ! error print
180         WRITE(numout,cform_err)
181         WRITE(numout,*) nstop, ' error have been found' 
182      ENDIF
183      !
184      CALL opa_tam_closefile
185#if defined key_oasis3 || defined key_oasis4
186      CALL ctl_stop( '       Key_oasis3 and key_oasis4 not available')
187#else
188      IF( lk_mpp )   CALL mppstop       ! end mpp communications
189#endif
190      !
191   END SUBROUTINE opa_tam_model
192
193
194   SUBROUTINE opa_tam_init
195      !!----------------------------------------------------------------------
196      !!                     ***  ROUTINE opa_tam_init  ***
197      !!
198      !! ** Purpose :   initialization of the opa model
199      !!
200      !!----------------------------------------------------------------------
201#if defined key_oasis3 || defined key_oasis4 || defined key_iomput
202      INTEGER :: ilocal_comm
203#endif
204      CHARACTER(len=80),DIMENSION(10) ::   cltxt = ''
205      INTEGER                         ::   ji   ! local loop indices
206      !!
207      NAMELIST/namctl/ ln_ctl  , nn_print, nn_ictls, nn_ictle,   &
208         &             nn_isplt, nn_jsplt, nn_jctls, nn_jctle, nn_bench, nn_bit_cmp
209      !!----------------------------------------------------------------------
210      !
211      !                             ! open Namelist file
212      CALL ctl_opn( numnam, 'namelist', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
213      !
214      READ( numnam, namctl )        ! Namelist namctl : Control prints & Benchmark
215      !
216      !                             !--------------------------------------------!
217      !                             !  set communicator & select the local node  !
218      !                             !--------------------------------------------!
219#if defined key_iomput
220      IF( Agrif_Root() ) THEN
221# if defined key_oasis3 || defined key_oasis4
222         CALL ctl_stop( '       Key_oasis3 and key_oasis4 not available')
223# endif
224         CALL ctl_stop( '       Agrif not available')
225      ENDIF
226      narea = mynode( cltxt, ilocal_comm )    ! Nodes selection
227#else
228# if defined key_oasis3 || defined key_oasis4
229      CALL ctl_stop( '       Key_oasis3 and key_oasis4 not available')
230# else
231      nproc = mynode( cltxt )                 ! Nodes selection (control print return in cltxt)
232# endif
233#endif
234      narea = nproc + 1                       ! mynode return the rank of proc (0 --> jpnij -1 )
235
236      lwp = (narea == 1) .OR. ln_ctl          ! control of all listing output print
237
238      IF(lwp) THEN                            ! open listing units
239         !
240         CALL ctl_opn( numout, 'opatam.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea )
241         !
242         WRITE(numout,*)
243         WRITE(numout,*) '         CNRS - NERC - Met OFFICE - MERCATOR-ocean'
244         WRITE(numout,*) '                       NEMO team'
245         WRITE(numout,*) '            Ocean General Circulation Model'
246         WRITE(numout,*) '                  version 3.2  (2009) '
247         WRITE(numout,*)
248         WRITE(numout,*)
249         DO ji = 1, SIZE(cltxt) 
250            IF( TRIM(cltxt(ji)) /= '' )   WRITE(numout,*) cltxt(ji)      ! control print of mynode
251         END DO
252         WRITE(numout,cform_aaa)                                         ! Flag AAAAAAA
253         !
254      ENDIF
255      !                             !--------------------------------!
256      !                             !  Model general initialization  !
257      !                             !--------------------------------!
258
259      CALL opa_tam_flg                          ! Control prints & Benchmark
260
261                                            ! Domain decomposition
262      IF( jpni*jpnj == jpnij ) THEN   ;   CALL mpp_init      ! standard cutting out
263      ELSE                            ;   CALL mpp_init2     ! eliminate land processors
264      ENDIF
265     
266      CALL phy_cst                          ! Physical constants
267      CALL eos_init                         ! Equation of state
268      CALL dom_cfg                          ! Domain configuration
269      CALL dom_init                         ! Domain
270      CALL tam_init
271!!gm c1d case can be moved in dom_init routine
272      IF( lk_c1d ) THEN                          ! 1D configuration
273            CALL ctl_stop( '       c1d not available')
274      ENDIF
275!!gm c1d end
276
277      IF( ln_ctl )   CALL prt_ctl_init      ! Print control
278
279      IF( lk_obc )   CALL obc_init          ! Open boundaries
280      IF( lk_bdy )   CALL ctl_stop( '    key_bdy not available')          ! Unstructured open boundaries
281
282      CALL istate_init                      ! ocean initial state (Dynamics and tracers)
283
284      !                                     ! Ocean physics
285      CALL sbc_init                             ! Read namsbc namelist : surface module (needed for iom_init)
286      CALL ldf_tra_init                         ! Lateral ocean tracer physics
287      CALL ldf_dyn_init                         ! Lateral ocean momentum physics
288      CALL zdf_init                             ! Vertical ocean physics
289
290#if defined key_top
291      CALL ctl_stop( '       top not available')
292#endif
293      !                                     ! diagnostics
294      CALL iom_init                             ! iom_put initialization
295      CALL dia_ptr_init                         ! Poleward TRansports initialization
296      CALL trd_mod_init                         ! Mixed-layer/Vorticity/Integral constraints trends
297      !
298      CALL     oce_tam_init( 0 )            ! OCE TAM field
299      CALL sol_oce_tam_init( 0 )            ! Initialize elliptic solver
300      CALL trc_oce_tam_init( 0 )            ! TRC TAM fields
301      CALL sbc_oce_tam_init( 0 )            ! SBC TAM fields
302      CALL sbc_init_tam
303      CALL tam_trj_init
304      !
305   END SUBROUTINE opa_tam_init
306
307
308   SUBROUTINE opa_tam_flg
309      !!----------------------------------------------------------------------
310      !!                     ***  ROUTINE opa  ***
311      !!
312      !! ** Purpose :   Initialise logical flags that control the choice of
313      !!              some algorithm or control print
314      !!
315      !! ** Method  : - print namctl information
316      !!              - Read in namilist namflg logical flags
317      !!----------------------------------------------------------------------
318      NAMELIST/namdyn_hpg/ ln_hpg_zco   , ln_hpg_zps   , ln_hpg_sco, ln_hpg_hel,   &
319         &                 ln_hpg_wdj   , ln_hpg_djc   , ln_hpg_rot, rn_gamma  ,   &
320         &                 ln_dynhpg_imp
321      !!----------------------------------------------------------------------
322
323      IF(lwp) THEN                 ! Parameter print
324         WRITE(numout,*)
325         WRITE(numout,*) 'opa_tam_flg: Control prints & Benchmark'
326         WRITE(numout,*) '~~~~~~~ '
327         WRITE(numout,*) '   Namelist namctl'
328         WRITE(numout,*) '      run control (for debugging)     ln_ctl     = ', ln_ctl
329         WRITE(numout,*) '      level of print                  nn_print   = ', nn_print
330         WRITE(numout,*) '      Start i indice for SUM control  nn_ictls   = ', nn_ictls
331         WRITE(numout,*) '      End i indice for SUM control    nn_ictle   = ', nn_ictle
332         WRITE(numout,*) '      Start j indice for SUM control  nn_jctls   = ', nn_jctls
333         WRITE(numout,*) '      End j indice for SUM control    nn_jctle   = ', nn_jctle
334         WRITE(numout,*) '      number of proc. following i     nn_isplt   = ', nn_isplt
335         WRITE(numout,*) '      number of proc. following j     nn_jsplt   = ', nn_jsplt
336         WRITE(numout,*) '      benchmark parameter (0/1)       nn_bench   = ', nn_bench
337         WRITE(numout,*) '      bit comparison mode (0/1)       nn_bit_cmp = ', nn_bit_cmp
338      ENDIF
339
340      nprint    = nn_print          ! convert DOCTOR namelist names into OLD names
341      nictls    = nn_ictls
342      nictle    = nn_ictle
343      njctls    = nn_jctls
344      njctle    = nn_jctle
345      isplt     = nn_isplt
346      jsplt     = nn_jsplt
347      nbench    = nn_bench
348      nbit_cmp  = nn_bit_cmp
349
350      !                           ! Parameter control
351      !
352      IF( ln_ctl ) THEN                 ! sub-domain area indices for the control prints
353         IF( lk_mpp ) THEN
354            isplt = jpni   ;   jsplt = jpnj   ;   ijsplt = jpni*jpnj   ! the domain is forced to the real splitted domain
355         ELSE
356            IF( isplt == 1 .AND. jsplt == 1  ) THEN
357               CALL ctl_warn( ' - isplt & jsplt are equal to 1',   &
358                  &           ' - the print control will be done over the whole domain' )
359            ENDIF
360            ijsplt = isplt * jsplt            ! total number of processors ijsplt
361         ENDIF
362         IF(lwp) WRITE(numout,*)'          - The total number of processors over which the'
363         IF(lwp) WRITE(numout,*)'            print control will be done is ijsplt : ', ijsplt
364         !
365         !                              ! indices used for the SUM control
366         IF( nictls+nictle+njctls+njctle == 0 )   THEN    ! print control done over the default area
367            lsp_area = .FALSE.                       
368         ELSE                                             ! print control done over a specific  area
369            lsp_area = .TRUE.
370            IF( nictls < 1 .OR. nictls > jpiglo )   THEN
371               CALL ctl_warn( '          - nictls must be 1<=nictls>=jpiglo, it is forced to 1' )
372               nictls = 1
373            ENDIF
374            IF( nictle < 1 .OR. nictle > jpiglo )   THEN
375               CALL ctl_warn( '          - nictle must be 1<=nictle>=jpiglo, it is forced to jpiglo' )
376               nictle = jpiglo
377            ENDIF
378            IF( njctls < 1 .OR. njctls > jpjglo )   THEN
379               CALL ctl_warn( '          - njctls must be 1<=njctls>=jpjglo, it is forced to 1' )
380               njctls = 1
381            ENDIF
382            IF( njctle < 1 .OR. njctle > jpjglo )   THEN
383               CALL ctl_warn( '          - njctle must be 1<=njctle>=jpjglo, it is forced to jpjglo' )
384               njctle = jpjglo
385            ENDIF
386         ENDIF
387      ENDIF
388
389      IF( nbench == 1 )   THEN            ! Benchmark
390         SELECT CASE ( cp_cfg )
391         CASE ( 'gyre' )   ;   CALL ctl_warn( ' The Benchmark is activated ' )
392         CASE DEFAULT      ;   CALL ctl_stop( ' The Benchmark is based on the GYRE configuration:',   &
393            &                                 ' key_gyre must be used or set nbench = 0' )
394         END SELECT
395      ENDIF
396
397      IF( nbit_cmp == 1 )   THEN          ! Bit compare
398         CALL ctl_warn( ' Bit comparison enabled. Single and multiple processor results must bit compare', &
399              &         ' WARNING: RESULTS ARE NOT PHYSICAL.' )
400      ENDIF
401
402      REWIND( numnam )              ! Read Namelist namdyn_hpg : ln_dynhpg_imp must be read at the initialisation phase
403      READ  ( numnam, namdyn_hpg )
404      !
405   END SUBROUTINE opa_tam_flg
406
407
408   SUBROUTINE opa_tam_closefile
409      !!----------------------------------------------------------------------
410      !!                     ***  ROUTINE opa_tam_closefile  ***
411      !!
412      !! ** Purpose :   Close the files
413      !!----------------------------------------------------------------------
414      USE dtatem        ! temperature data
415      USE dtasal        ! salinity data
416      !!----------------------------------------------------------------------
417      !
418      IF( lk_mpp )   CALL mppsync
419      !
420      CALL iom_close                                 ! close all input/output files managed by iom_*
421      !
422      IF( numstp     /= -1 )   CLOSE( numstp     )   ! time-step file
423      IF( numsol     /= -1 )   CLOSE( numsol     )   ! solver file
424      IF( numnam     /= -1 )   CLOSE( numnam     )   ! oce namelist
425      IF( numnam_ice /= -1 )   CLOSE( numnam_ice )   ! ice namelist
426      IF( numevo_ice /= -1 )   CLOSE( numevo_ice )   ! ice variables (temp. evolution)
427      IF( numout     /=  6 )   CLOSE( numout     )   ! standard model output file
428      numout = 6   ! redefine numout in case it is used after this point...
429      !
430   END SUBROUTINE opa_tam_closefile
431
432   !!======================================================================
433#endif
434END MODULE opa_tam
Note: See TracBrowser for help on using the repository browser.