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.F90 in branches/dev_003_CPL/NEMO/OPA_SRC – NEMO

source: branches/dev_003_CPL/NEMO/OPA_SRC/opa.F90 @ 991

Last change on this file since 991 was 991, checked in by smasson, 16 years ago

dev_003_CPL: preliminary draft (not working), see ticket #155

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 18.4 KB
Line 
1MODULE opa
2   !!==============================================================================
3   !!                       ***  MODULE opa   ***
4   !! Ocean system   : OPA ocean dynamics (including on-line tracers and sea-ice)
5   !!==============================================================================
6
7   !!----------------------------------------------------------------------
8   !!   opa_model      : solve ocean dynamics, tracer and/or sea-ice
9   !!   opa_init       : initialization of the opa model
10   !!   opa_flg        : initialisation of algorithm flag
11   !!   opa_closefile  : close remaining files
12   !!----------------------------------------------------------------------
13   !! History :
14   !!   4.0  !  90-10  (C. Levy, G. Madec)  Original code
15   !!   7.0  !  91-11  (M. Imbard, C. Levy, G. Madec)
16   !!   7.1  !  93-03  (M. Imbard, C. Levy, G. Madec, O. Marti,
17   !!                   M. Guyon, A. Lazar, P. Delecluse, C. Perigaud,
18   !!                   G. Caniaux, B. Colot, C. Maes ) release 7.1
19   !!        !  92-06  (L.Terray) coupling implementation
20   !!        !  93-11  (M.A. Filiberti) IGLOO sea-ice
21   !!   8.0  !  96-03  (M. Imbard, C. Levy, G. Madec, O. Marti,
22   !!                   M. Guyon, A. Lazar, P. Delecluse, L.Terray,
23   !!                   M.A. Filiberti, J. Vialar, A.M. Treguier,
24   !!                   M. Levy)  release 8.0
25   !!   8.1  !  97-06  (M. Imbard, G. Madec)
26   !!   8.2  !  99-11  (M. Imbard, H. Goosse)  LIM sea-ice model
27   !!        !  99-12  (V. Thierry, A-M. Treguier, M. Imbard, M-A. Foujols)  OPEN-MP
28   !!        !  00-07  (J-M Molines, M. Imbard)  Open Boundary Conditions  (CLIPPER)
29   !!   9.0  !  02-08  (G. Madec)  F90: Free form and modules
30   !!    "   !  04-06  (R. Redler, NEC CCRLE, Germany) add OASIS[3/4] coupled interfaces
31   !!    "   !  04-08  (C. Talandier) New trends organization
32   !!    "   !  05-06  (C. Ethe) Add the 1D configuration possibility
33   !!    "   !  05-11  (V. Garnier) Surface pressure gradient organization
34   !!    "   !  06-03  (L. Debreu, C. Mazauric)  Agrif implementation
35   !!    "   !  06-04  (G. Madec, R. Benshila)  Step reorganization
36   !!    "   !  07-07  (J. Chanut, A. Sellar) Unstructured open boundaries (BDY)
37   !!----------------------------------------------------------------------
38   !! * Modules used
39   USE oce             ! dynamics and tracers variables
40   USE dom_oce         ! ocean space domain variables
41   USE sbc_oce         ! surface boundary condition: ocean
42   USE trdmod_oce      ! ocean variables trends
43   USE daymod          ! calendar
44   USE in_out_manager  ! I/O manager
45   USE lib_mpp         ! distributed memory computing
46
47   USE domcfg          ! domain configuration               (dom_cfg routine)
48   USE mppini          ! shared/distributed memory setting (mpp_init routine)
49   USE domain          ! domain initialization             (dom_init routine)
50   USE obc_par         ! open boundary cond. parameters
51   USE obcini          ! open boundary cond. initialization (obc_ini routine)
52   USE bdy_par         ! unstructured open boundary cond. parameters
53   USE bdyini          ! unstructured open boundary cond. initialization (bdy_init routine)
54   USE bdytides        ! tides at open boundaries initialization (lk_bdy_tides)
55   USE istate          ! initial state setting          (istate_init routine)
56   USE eosbn2          ! equation of state            (eos bn2 routine)
57   USE zpshde          ! partial step: hor. derivative (zps_hde routine)
58
59   ! ocean physics
60   USE ldfdyn          ! lateral viscosity setting      (ldfdyn_init routine)
61   USE ldftra          ! lateral diffusivity setting    (ldftra_init routine)
62   USE zdfini
63
64   USE phycst          ! physical constant                  (par_cst routine)
65   USE ocfzpt          ! ocean freezing point              (oc_fz_pt routine)
66   USE trdmod          ! momentum/tracers trends       (trd_mod_init routine)
67
68   USE diaptr          ! poleward transports           (dia_ptr_init routine)
69
70   USE step            ! OPA time-stepping                  (stp     routine)
71   USE cpl_oasis3      ! OASIS3 coupling
72   USE dynspg_oce      ! Control choice of surface pressure gradient schemes
73   USE prtctl          ! Print control                 (prt_ctl_init routine)
74   USE c1d             ! 1D configuration
75   USE dyncor_c1d      ! Coriolis factor at T-point
76   USE step_c1d        ! Time stepping loop for the 1D configuration
77
78   USE initrc          ! Initialization of the passive tracers
79
80   IMPLICIT NONE
81   PRIVATE
82
83   !! * Module variables
84   CHARACTER (len=64) ::        &
85      cform_aaa="( /, 'AAAAAAAA', / ) "     ! flag for output listing
86
87   !! * Routine accessibility
88   PUBLIC opa_model      ! called by model.F90
89   PUBLIC opa_init
90   !!----------------------------------------------------------------------
91   !!  OPA 9.0 , LOCEAN-IPSL (2005)
92   !! $Id$
93   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
94   !!----------------------------------------------------------------------
95
96CONTAINS
97
98   SUBROUTINE opa_model
99      !!----------------------------------------------------------------------
100      !!                     ***  ROUTINE opa  ***
101      !!
102      !! ** Purpose :   opa solves the primitive equations on an orthogonal
103      !!      curvilinear mesh on the sphere.
104      !!
105      !! ** Method  : - model general initialization
106      !!              - launch the time-stepping (stp routine)
107      !!
108      !! References :
109      !!      Madec, Delecluse,Imbard, and Levy, 1997: reference manual.
110      !!              internal report, IPSL.
111      !!----------------------------------------------------------------------
112      INTEGER ::   istp       ! time step index
113      !!----------------------------------------------------------------------
114
115#if defined key_agrif
116      CALL Agrif_Init_Grids()
117#endif
118     
119      CALL opa_init  ! Initializations
120
121      ! check that all process are still there... If some process have an error,
122      ! they will never enter in step and other processes will wait until the end of the cpu time!
123      IF( lk_mpp )   CALL mpp_max( nstop )
124
125      istp = nit000
126      IF( lk_c1d ) THEN                 ! 1D configuration (no AGRIF zoom)
127         !
128         DO WHILE ( istp <= nitend .AND. nstop == 0 )
129            CALL stp_c1d( istp )
130            istp = istp + 1
131         END DO
132      ELSE                              ! 3D ocean with or without AGRIF zoom
133         !
134         DO WHILE ( istp <= nitend .AND. nstop == 0 )
135#if defined key_agrif
136            CALL Agrif_Step( stp )
137#else
138            CALL stp( istp )
139#endif
140            istp = istp + 1
141            IF( lk_mpp )   CALL mpp_max( nstop )
142         END DO
143      ENDIF
144      !                                     ! ========= !
145      !                                     !  Job end  !
146      !                                     ! ========= !
147
148      IF(lwp) WRITE(numout,cform_aaa)       ! Flag AAAAAAA
149
150      IF( nstop /= 0 .AND. lwp ) THEN                 ! error print
151         WRITE(numout,cform_err)
152         WRITE(numout,*) nstop, ' error have been found' 
153      ENDIF
154
155      CALL opa_closefile
156      IF      ( lk_cpl ) THEN   ;   CALL cpl_prism_finalize
157      ELSE IF ( lk_mpp ) THEN   ;   CALL mppstop                ! Close all files (mpp)
158      ENDIF
159                         
160   END SUBROUTINE opa_model
161
162
163   SUBROUTINE opa_init
164      !!----------------------------------------------------------------------
165      !!                     ***  ROUTINE opa_init  ***
166      !!
167      !! ** Purpose :   initialization of the opa model
168      !!
169      !!----------------------------------------------------------------------
170      INTEGER :: localComm
171      CHARACTER (len=20) ::   namelistname
172      CHARACTER (len=28) ::   file_out
173      NAMELIST/namctl/ ln_ctl, nprint, nictls, nictle,   &
174         &             isplt , jsplt , njctls, njctle, nbench, nbit_cmp
175      !!----------------------------------------------------------------------
176
177      ! Initializations
178      ! ===============
179
180      file_out = 'ocean.output'
181     
182      ! open listing and namelist units
183      CALL ctlopn( numout, file_out, 'UNKNOWN', 'FORMATTED',   &
184         &         'SEQUENTIAL', 1, 6, .FALSE., 1 )
185
186      WRITE(numout,*)
187      WRITE(numout,*) '                 L O D Y C - I P S L'
188      WRITE(numout,*) '                     O P A model'
189      WRITE(numout,*) '            Ocean General Circulation Model'
190      WRITE(numout,*) '               version OPA 9.0  (2005) '
191      WRITE(numout,*)
192      WRITE(numout,*)
193
194      namelistname = 'namelist'
195      CALL ctlopn( numnam, namelistname, 'OLD', 'FORMATTED', 'SEQUENTIAL',   &
196         &         1, numout, .FALSE., 1 )
197
198      ! Namelist namctl : Control prints & Benchmark
199      REWIND( numnam )
200      READ  ( numnam, namctl )
201
202      IF ( lk_cpl ) THEN
203         CALL cpl_prism_init()
204         narea = mynode(nlocalComm)
205      ELSE
206         narea = mynode()
207      ENDIF
208         
209      narea = narea + 1    ! mynode return the rank of proc (0 --> jpnij -1 )
210      lwp   = narea == 1
211
212      ! open additionnal listing
213      IF( ln_ctl )   THEN
214         IF( narea-1 > 0 )   THEN
215            WRITE(file_out,FMT="('ocean.output_',I4.4)") narea-1
216            CALL ctlopn( numout, file_out, 'UNKNOWN', 'FORMATTED',   &
217               &         'SEQUENTIAL', 1, numout, .FALSE., 1 )
218            lwp = .TRUE.
219            !
220            WRITE(numout,*)
221            WRITE(numout,*) '                 L O D Y C - I P S L'
222            WRITE(numout,*) '                     O P A model'
223            WRITE(numout,*) '            Ocean General Circulation Model'
224            WRITE(numout,*) '               version OPA 9.0  (2005) '
225            WRITE(numout,*) '                   MPI Ocean output '
226            WRITE(numout,*)
227            WRITE(numout,*)
228         ENDIF
229      ENDIF
230
231      !                                     ! ============================== !
232      !                                     !  Model general initialization  !
233      !                                     ! ============================== !
234
235      IF(lwp) WRITE(numout,cform_aaa)       ! Flag AAAAAAA
236
237      CALL opa_flg                          ! Control prints & Benchmark
238
239                                            ! Domain decomposition
240      IF( jpni*jpnj == jpnij ) THEN
241         CALL mpp_init                          ! standard cutting out
242      ELSE
243         CALL mpp_init2                         ! eliminate land processors
244      ENDIF
245     
246      CALL phy_cst                          ! Physical constants
247
248      CALL dom_cfg                          ! Domain configuration
249     
250      CALL dom_init                         ! Domain
251
252      IF( lk_c1d    ) THEN                      ! adaptation for 1D configuration
253         CALL cor_c1d                                ! redefine Coriolis at T-point
254         umask(:,:,:) = tmask(:,:,:)                 ! U, V and T-points are the same
255         vmask(:,:,:) = tmask(:,:,:)                 !
256      ENDIF
257
258      IF( ln_ctl    )   CALL prt_ctl_init   ! Print control
259
260      IF( lk_obc    )   CALL obc_init       ! Open boundaries
261
262      IF( lk_bdy .OR. lk_bdy_tides )   &
263         &              CALL bdy_init       ! Unstructured open boundaries
264
265      CALL istate_init                      ! ocean initial state (Dynamics and tracers)
266
267      CALL oc_fz_pt                         ! Surface freezing point
268
269      !                                     ! Ocean physics
270
271      CALL ldf_dyn_init                         ! Lateral ocean momentum physics
272
273      CALL ldf_tra_init                         ! Lateral ocean tracer physics
274
275      CALL zdf_init                             ! Vertical ocean physics
276
277      CALL trd_mod_init                         ! Mixed-layer/Vorticity/Integral constraints trends
278
279#if defined key_top
280      CALL ini_trc                           ! Passive tracers
281#endif
282
283      CALL dia_ptr_init                     ! Poleward TRansports initialization
284
285      !                                     ! =============== !
286      !                                     !  time stepping  !
287      !                                     ! =============== !
288
289      IF(lwp) WRITE(numout,cform_aaa)       ! Flag AAAAAAA
290
291   END SUBROUTINE opa_init
292
293
294   SUBROUTINE opa_flg
295      !!----------------------------------------------------------------------
296      !!                     ***  ROUTINE opa  ***
297      !!
298      !! ** Purpose :   Initialize logical flags that control the choice of
299      !!      some algorithm or control print
300      !!
301      !! ** Method  :    Read in namilist namflg logical flags
302      !!
303      !! History :
304      !!   9.0  !  03-11  (G. Madec)  Original code
305      !!----------------------------------------------------------------------
306      !! * Local declarations
307
308      NAMELIST/namflg/ ln_dynhpg_imp, nn_dynhpg_rst
309      !!----------------------------------------------------------------------
310
311      ! Parameter control and print
312      ! ---------------------------
313      IF(lwp) THEN
314         WRITE(numout,*)
315         WRITE(numout,*) 'opa_flg: Control prints & Benchmark'
316         WRITE(numout,*) '~~~~~~~ '
317         WRITE(numout,*) '          Namelist namctl'
318         WRITE(numout,*) '             run control (for debugging)     ln_ctl    = ', ln_ctl
319         WRITE(numout,*) '             level of print                  nprint    = ', nprint
320         WRITE(numout,*) '             Start i indice for SUM control  nictls    = ', nictls
321         WRITE(numout,*) '             End i indice for SUM control    nictle    = ', nictle
322         WRITE(numout,*) '             Start j indice for SUM control  njctls    = ', njctls
323         WRITE(numout,*) '             End j indice for SUM control    njctle    = ', njctle
324         WRITE(numout,*) '             number of proc. following i     isplt     = ', isplt
325         WRITE(numout,*) '             number of proc. following j     jsplt     = ', jsplt
326         WRITE(numout,*) '             benchmark parameter (0/1)       nbench    = ', nbench
327         WRITE(numout,*) '             bit comparison mode (0/1)       nbit_cmp  = ', nbit_cmp
328      ENDIF
329
330      ! ... Control the sub-domain area indices for the control prints
331      IF( ln_ctl )   THEN
332         IF( lk_mpp )   THEN
333            ! the domain is forced to the real splitted domain in MPI
334            isplt = jpni ; jsplt = jpnj ; ijsplt = jpni*jpnj
335         ELSE
336            IF( isplt == 1 .AND. jsplt == 1  ) THEN
337               CALL ctl_warn( '          - isplt & jsplt are equal to 1',   &
338                    &         '          - the print control will be done over the whole domain' )
339            ENDIF
340
341            ! compute the total number of processors ijsplt
342            ijsplt = isplt*jsplt
343         ENDIF
344
345         IF(lwp) WRITE(numout,*)'          - The total number of processors over which the'
346         IF(lwp) WRITE(numout,*)'            print control will be done is ijsplt : ', ijsplt
347
348         ! Control the indices used for the SUM control
349         IF( nictls+nictle+njctls+njctle == 0 )   THEN
350            ! the print control is done over the default area
351            lsp_area = .FALSE.
352         ELSE
353            ! the print control is done over a specific  area
354            lsp_area = .TRUE.
355            IF( nictls < 1 .OR. nictls > jpiglo )   THEN
356               CALL ctl_warn( '          - nictls must be 1<=nictls>=jpiglo, it is forced to 1' )
357               nictls = 1
358            ENDIF
359
360            IF( nictle < 1 .OR. nictle > jpiglo )   THEN
361               CALL ctl_warn( '          - nictle must be 1<=nictle>=jpiglo, it is forced to jpiglo' )
362               nictle = jpiglo
363            ENDIF
364
365            IF( njctls < 1 .OR. njctls > jpjglo )   THEN
366               CALL ctl_warn( '          - njctls must be 1<=njctls>=jpjglo, it is forced to 1' )
367               njctls = 1
368            ENDIF
369
370            IF( njctle < 1 .OR. njctle > jpjglo )   THEN
371               CALL ctl_warn( '          - njctle must be 1<=njctle>=jpjglo, it is forced to jpjglo' )
372               njctle = jpjglo
373            ENDIF
374
375         ENDIF          ! IF( nictls+nictle+njctls+njctle == 0 )
376       ENDIF            ! IF(ln_ctl)
377
378      IF( nbench == 1 )   THEN
379         SELECT CASE ( cp_cfg )
380         CASE ( 'gyre' )
381            CALL ctl_warn( '          The Benchmark is activated ' )
382         CASE DEFAULT
383            CALL ctl_stop( '          The Benchmark is based on the GYRE configuration: key_gyre must &
384               &                      be used or set nbench = 0' )
385         END SELECT
386      ENDIF
387
388      IF( nbit_cmp == 1 )   THEN
389         CALL ctl_warn( '          Bit comparison enabled. Single and multiple processor results must bit compare', &
390              &         '          WARNING: RESULTS ARE NOT PHYSICAL.' )
391      ENDIF
392
393
394      ! Read Namelist namflg : algorithm FLaG
395      ! --------------------
396      REWIND ( numnam )
397      READ   ( numnam, namflg )
398
399      ! Parameter control and print
400      ! ---------------------------
401      IF(lwp) THEN
402         WRITE(numout,*)
403         WRITE(numout,*) 'opa_flg : Hydrostatic pressure gradient algorithm'
404         WRITE(numout,*) '~~~~~~~'
405         WRITE(numout,*) '          Namelist namflg : set algorithm flags'
406         WRITE(numout,*) '             centered (F) or semi-implicit (T)   ln_dynhpg_imp = ', ln_dynhpg_imp
407         WRITE(numout,*) '             hydrostatic pressure gradient'
408         WRITE(numout,*) '             add dynhpg implicit variable        nn_dynhpg_rst = ', nn_dynhpg_rst
409         WRITE(numout,*) '             in restart ot not nn_dynhpg_rst'
410      ENDIF
411      IF( .NOT. ln_dynhpg_imp )   nn_dynhpg_rst = 0      ! force no adding dynhpg implicit variables in restart
412
413   END SUBROUTINE opa_flg
414
415
416   SUBROUTINE opa_closefile
417      !!----------------------------------------------------------------------
418      !!                     ***  ROUTINE opa_closefile  ***
419      !!
420      !! ** Purpose :   Close the files
421      !!
422      !! ** Method  :
423      !!
424      !! History :
425      !!   9.0  !  05-01  (O. Le Galloudec)  Original code
426      !!----------------------------------------------------------------------
427      !! * Modules used
428      USE dtatem        ! temperature data
429      USE dtasal        ! salinity data
430      !!----------------------------------------------------------------------
431
432      IF ( lk_mpp ) CALL mppsync
433
434      ! 1. Unit close
435      ! -------------
436
437      CLOSE( numnam )           ! namelist
438      CLOSE( numout )           ! standard model output file
439
440      IF(lwp) CLOSE( numstp )   ! time-step file
441      IF(lwp) CLOSE( numsol )
442
443   END SUBROUTINE opa_closefile
444
445   !!======================================================================
446END MODULE opa
Note: See TracBrowser for help on using the repository browser.