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

source: trunk/NEMOGCM/NEMO/OFF_SRC/opa.F90 @ 2528

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

Update NEMOGCM from branch nemo_v3_3_beta

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