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/nemo_v3_3_beta/NEMOGCM/NEMO/OFF_SRC – NEMO

source: branches/nemo_v3_3_beta/NEMOGCM/NEMO/OFF_SRC/opa.F90 @ 2444

Last change on this file since 2444 was 2444, checked in by cetlod, 13 years ago

Improvment of OFFLINE in v3.3beta (review done by gm) : clean the style in all routines, suppression of key_zdfddm

  • Property svn:keywords set to Id
File size: 15.3 KB
Line 
1MODULE opa
2   !!======================================================================
3   !!                       ***  MODULE opa   ***
4   !! Off-line Ocean   : passive tracer evolution, dynamics read in files
5   !!======================================================================
6   !! History :  3.3  ! 2010-05  (C. Ethe)  Full reorganization of the off-line: phasing with the on-line
7   !!----------------------------------------------------------------------
8
9   !!----------------------------------------------------------------------
10   !!   opa_model      : off-line: solve ocean tracer only
11   !!   opa_init       : initialization of the opa model
12   !!   opa_ctl        : initialisation of algorithm flag
13   !!   opa_closefile  : close remaining files
14   !!----------------------------------------------------------------------
15   USE dom_oce         ! ocean space domain variables
16   USE oce             ! dynamics and tracers variables
17   USE c1d             ! 1D configuration
18   USE domcfg          ! domain configuration               (dom_cfg routine)
19   USE domain          ! domain initialization             (dom_init routine)
20   USE istate          ! initial state setting          (istate_init routine)
21   USE eosbn2          ! equation of state            (eos bn2 routine)
22   !              ! ocean physics
23   USE ldftra          ! lateral diffusivity setting    (ldf_tra_init routine)
24   USE ldfslp          ! slopes of neutral surfaces     (ldf_slp_init routine)
25   USE traqsr          ! solar radiation penetration    (tra_qsr_init routine)
26   USE trabbl          ! bottom boundary layer          (tra_bbl_init routine)
27   USE zpshde          ! partial step: hor. derivative  (zps_hde_init routine)
28   USE zdfini          ! vertical physics: initialization
29   USE phycst          ! physical constant                  (par_cst routine)
30   USE dtadyn          ! Lecture and Interpolation of the dynamical fields
31   USE trcini          ! Initilization of the passive tracers
32   USE daymod          ! calendar                         (day     routine)
33   USE trcstp          ! passive tracer time-stepping      (trc_stp routine)
34   USE dtadyn          ! Lecture and interpolation of the dynamical fields
35   USE stpctl          ! time stepping control            (stp_ctl routine)
36   !              ! I/O & MPP
37   USE iom             ! I/O library
38   USE in_out_manager  ! I/O manager
39   USE mppini          ! shared/distributed memory setting (mpp_init routine)
40   USE lib_mpp         ! distributed memory computing
41#if defined key_iomput
42   USE  mod_ioclient
43#endif
44
45   IMPLICIT NONE
46   PRIVATE
47   
48   PUBLIC   opa_model   ! called by model.F90
49
50   CHARACTER (len=64) ::   cform_aaa="( /, 'AAAAAAAA', / ) "   ! flag for output listing
51
52   !!----------------------------------------------------------------------
53   !! NEMO/OFF 3.3 , NEMO Consortium (2010)
54   !! $Id$
55   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
56   !!----------------------------------------------------------------------
57CONTAINS
58
59   SUBROUTINE opa_model
60      !!----------------------------------------------------------------------
61      !!                     ***  ROUTINE opa  ***
62      !!
63      !! ** Purpose :   opa solves the primitive equations on an orthogonal
64      !!      curvilinear mesh on the sphere.
65      !!
66      !! ** Method  : - model general initialization
67      !!              - launch the time-stepping (dta_dyn and trc_stp)
68      !!              - finalize the run by closing files and communications
69      !!
70      !! References : Madec, Delecluse,Imbard, and Levy, 1997:  internal report, IPSL.
71      !!              Madec, 2008, internal report, IPSL.
72      !!----------------------------------------------------------------------
73      INTEGER :: istp, indic       ! time step index
74      !!----------------------------------------------------------------------
75
76      CALL opa_init  ! Initializations
77
78      IF( lk_mpp )   CALL mpp_max( nstop )
79
80      ! check that all process are still there... If some process have an error,
81      ! they will never enter in step and other processes will wait until the end of the cpu time!
82      IF( lk_mpp )   CALL mpp_max( nstop )
83
84      !                            !-----------------------!
85      !                            !==   time stepping   ==!
86      !                            !-----------------------!
87      istp = nit000
88         !
89      DO WHILE ( istp <= nitend .AND. nstop == 0 )    ! time stepping
90         !
91         IF( istp /= nit000 )   CALL day      ( istp )         ! Calendar (day was already called at nit000 in day_init)
92                                CALL iom_setkt( istp )         ! say to iom that we are at time step kstp
93                                CALL dta_dyn  ( istp )         ! Interpolation of the dynamical fields
94                                CALL trc_stp  ( istp )         ! time-stepping
95                                CALL stp_ctl  ( istp, indic )  ! Time loop: control and print
96         istp = istp + 1
97         IF( lk_mpp )   CALL mpp_max( nstop )
98      END DO
99
100      !                            !------------------------!
101      !                            !==  finalize the run  ==!
102      !                            !------------------------!
103      IF(lwp) WRITE(numout,cform_aaa)                 ! Flag AAAAAAA
104
105      IF( nstop /= 0 .AND. lwp ) THEN                 ! error print
106         WRITE(numout,cform_err)
107         WRITE(numout,*) nstop, ' error have been found'
108      ENDIF
109      !
110      CALL opa_closefile
111      !
112      IF( lk_mpp )   CALL mppstop                          ! Close all files (mpp)
113      !
114   END SUBROUTINE opa_model
115
116
117   SUBROUTINE opa_init
118      !!----------------------------------------------------------------------
119      !!                     ***  ROUTINE opa_init ***
120      !!
121      !! ** Purpose :   initialization of the opa model in off-line mode
122      !!----------------------------------------------------------------------
123      INTEGER ::   ji            ! dummy loop indices
124      INTEGER ::   ilocal_comm   ! local integer
125      CHARACTER(len=80), DIMENSION(10) ::   cltxt = ''
126      !!
127      NAMELIST/namctl/ ln_ctl  , nn_print, nn_ictls, nn_ictle,   &
128         &             nn_isplt, nn_jsplt, nn_jctls, nn_jctle, nn_bench
129      !!----------------------------------------------------------------------
130      !
131      !                             ! open Namelist file     
132      CALL ctl_opn( numnam, 'namelist', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
133      !
134      READ( numnam, namctl )        ! Namelist namctl : Control prints & Benchmark
135      !
136      !                             !--------------------------------------------!
137      !                             !  set communicator & select the local node  !
138      !                             !--------------------------------------------!
139#if defined key_iomput
140      CALL init_ioclient( ilocal_comm )       ! nemo local communicator (used or not) given by the io_server
141      narea = mynode( cltxt, ilocal_comm )    ! Nodes selection
142#else
143      narea = mynode( cltxt )                 ! Nodes selection (control print return in cltxt)
144#endif
145      narea = narea + 1                       ! mynode return the rank of proc (0 --> jpnij -1 )
146
147      lwp = (narea == 1) .OR. ln_ctl          ! control of all listing output print
148
149      IF(lwp) THEN                            ! open listing units
150         !
151         CALL ctl_opn( numout, 'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea )
152         !
153         WRITE(numout,*)
154         WRITE(numout,*) '         CNRS - NERC - Met OFFICE - MERCATOR-ocean'
155         WRITE(numout,*) '                       NEMO team'
156         WRITE(numout,*) '            Ocean General Circulation Model'
157         WRITE(numout,*) '                  version 3.3  (2010) '
158         WRITE(numout,*)
159         WRITE(numout,*)
160         DO ji = 1, SIZE(cltxt) 
161            IF( TRIM(cltxt(ji)) /= '' )   WRITE(numout,*) cltxt(ji)      ! control print of mynode
162         END DO
163         WRITE(numout,cform_aaa)                                         ! Flag AAAAAAA
164         !
165      ENDIF
166      !                             !--------------------------------!
167      !                             !  Model general initialization  !
168      !                             !--------------------------------!
169
170      CALL opa_ctl                           ! Control prints & Benchmark
171
172      !                                      ! Domain decomposition
173      IF( jpni*jpnj == jpnij ) THEN   ;   CALL mpp_init      ! standard cutting out
174      ELSE                            ;   CALL mpp_init2     ! eliminate land processors
175      ENDIF
176      !
177      !                                      ! General initialization
178                            CALL     phy_cst    ! Physical constants
179                            CALL     eos_init   ! Equation of state
180                            CALL     dom_cfg    ! Domain configuration
181                            CALL     dom_init   ! Domain
182
183      IF( ln_zps        )   CALL zps_hde_init   ! Partial steps:  horizontal derivative
184                            CALL  istate_init   ! ocean initial state (Dynamics and tracers)
185
186      !                                     ! Ocean physics
187#if ! defined key_degrad
188                            CALL ldf_tra_init   ! Lateral ocean tracer physics
189#endif
190      IF( lk_ldfslp )       CALL ldf_slp_init   ! slope of lateral mixing
191
192      !                                     ! Active tracers
193                            CALL tra_qsr_init   ! penetrative solar radiation qsr
194      IF( lk_trabbl     )   CALL tra_bbl_init   ! advective (and/or diffusive) bottom boundary layer scheme
195
196      !                                     ! Passive tracers
197                            CALL     trc_init   ! Passive tracers initialization
198      !                                     ! Dynamics
199                            CALL dta_dyn_init   ! Initialization for the dynamics
200                            CALL     iom_init       ! iom_put initialization
201
202      IF(lwp) WRITE(numout,cform_aaa)       ! Flag AAAAAAA
203      !
204   END SUBROUTINE opa_init
205
206
207   SUBROUTINE opa_ctl
208      !!----------------------------------------------------------------------
209      !!                     ***  ROUTINE opa_ctl  ***
210      !!
211      !! ** Purpose :   control print setting
212      !!
213      !! ** Method  : - print namctl information and check some consistencies
214      !!----------------------------------------------------------------------
215      !
216      IF(lwp) THEN                  ! Parameter print
217         WRITE(numout,*)
218         WRITE(numout,*) 'opa_flg: Control prints & Benchmark'
219         WRITE(numout,*) '~~~~~~~ '
220         WRITE(numout,*) '   Namelist namctl'
221         WRITE(numout,*) '      run control (for debugging)     ln_ctl     = ', ln_ctl
222         WRITE(numout,*) '      level of print                  nn_print   = ', nn_print
223         WRITE(numout,*) '      Start i indice for SUM control  nn_ictls   = ', nn_ictls
224         WRITE(numout,*) '      End i indice for SUM control    nn_ictle   = ', nn_ictle
225         WRITE(numout,*) '      Start j indice for SUM control  nn_jctls   = ', nn_jctls
226         WRITE(numout,*) '      End j indice for SUM control    nn_jctle   = ', nn_jctle
227         WRITE(numout,*) '      number of proc. following i     nn_isplt   = ', nn_isplt
228         WRITE(numout,*) '      number of proc. following j     nn_jsplt   = ', nn_jsplt
229         WRITE(numout,*) '      benchmark parameter (0/1)       nn_bench   = ', nn_bench
230      ENDIF
231      !
232      nprint    = nn_print          ! convert DOCTOR namelist names into OLD names
233      nictls    = nn_ictls
234      nictle    = nn_ictle
235      njctls    = nn_jctls
236      njctle    = nn_jctle
237      isplt     = nn_isplt
238      jsplt     = nn_jsplt
239      nbench    = nn_bench
240      !                             ! Parameter control
241      !
242      IF( ln_ctl ) THEN                 ! sub-domain area indices for the control prints
243         IF( lk_mpp ) THEN
244            isplt = jpni   ;   jsplt = jpnj   ;   ijsplt = jpni*jpnj   ! the domain is forced to the real splitted domain
245         ELSE
246            IF( isplt == 1 .AND. jsplt == 1  ) THEN
247               CALL ctl_warn( ' - isplt & jsplt are equal to 1',   &
248                  &           ' - the print control will be done over the whole domain' )
249            ENDIF
250            ijsplt = isplt * jsplt            ! total number of processors ijsplt
251         ENDIF
252         IF(lwp) WRITE(numout,*)'          - The total number of processors over which the'
253         IF(lwp) WRITE(numout,*)'            print control will be done is ijsplt : ', ijsplt
254         !
255         !                              ! indices used for the SUM control
256         IF( nictls+nictle+njctls+njctle == 0 )   THEN    ! print control done over the default area
257            lsp_area = .FALSE.
258         ELSE                                             ! print control done over a specific  area
259            lsp_area = .TRUE.
260            IF( nictls < 1 .OR. nictls > jpiglo )   THEN
261               CALL ctl_warn( '          - nictls must be 1<=nictls>=jpiglo, it is forced to 1' )
262               nictls = 1
263            ENDIF
264            IF( nictle < 1 .OR. nictle > jpiglo )   THEN
265               CALL ctl_warn( '          - nictle must be 1<=nictle>=jpiglo, it is forced to jpiglo' )
266               nictle = jpiglo
267            ENDIF
268            IF( njctls < 1 .OR. njctls > jpjglo )   THEN
269               CALL ctl_warn( '          - njctls must be 1<=njctls>=jpjglo, it is forced to 1' )
270               njctls = 1
271            ENDIF
272            IF( njctle < 1 .OR. njctle > jpjglo )   THEN
273               CALL ctl_warn( '          - njctle must be 1<=njctle>=jpjglo, it is forced to jpjglo' )
274               njctle = jpjglo
275            ENDIF
276         ENDIF
277      ENDIF
278      !
279      IF( nbench == 1 )   THEN            ! Benchmark
280         SELECT CASE ( cp_cfg )
281         CASE ( 'gyre' )   ;   CALL ctl_warn( ' The Benchmark is activated ' )
282         CASE DEFAULT      ;   CALL ctl_stop( ' The Benchmark is based on the GYRE configuration:',   &
283            &                                 ' key_gyre must be used or set nbench = 0' )
284         END SELECT
285      ENDIF
286      !
287      IF( lk_c1d .AND. .NOT.lk_iomput )   CALL ctl_stop( 'opa_ctl: The 1D configuration must be used ',   &
288         &                                               'with the IOM Input/Output manager. '        ,   &
289         &                                               'Compile with key_iomput enabled' )
290      !
291   END SUBROUTINE opa_ctl
292
293
294   SUBROUTINE opa_closefile
295      !!----------------------------------------------------------------------
296      !!                     ***  ROUTINE opa_closefile  ***
297      !!
298      !! ** Purpose :   Close the files
299      !!----------------------------------------------------------------------
300      !
301      IF ( lk_mpp ) CALL mppsync
302      !
303      CALL iom_close                                 ! close all input/output files managed by iom_*
304      !
305      IF( numstp     /= -1 )   CLOSE( numstp     )   ! time-step file
306      IF( numnam     /= -1 )   CLOSE( numnam     )   ! oce namelist
307      IF( numout     /=  6 )   CLOSE( numout     )   ! standard model output file
308      numout = 6                                     ! redefine numout in case it is used after this point...
309      !
310   END SUBROUTINE opa_closefile
311
312   !!======================================================================
313END MODULE opa
Note: See TracBrowser for help on using the repository browser.