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.
solver.F90 in branches/UKMO/test_moci_test_suite_namelist_read/NEMOGCM/NEMO/OPA_SRC/SOL – NEMO

source: branches/UKMO/test_moci_test_suite_namelist_read/NEMOGCM/NEMO/OPA_SRC/SOL/solver.F90 @ 9383

Last change on this file since 9383 was 9383, checked in by andmirek, 6 years ago

#2050 fixes and changes

File size: 7.8 KB
Line 
1MODULE solver
2   !!======================================================================
3   !!                     ***  MODULE  solver  ***
4   !! Ocean solver :  initialization of ocean solver
5   !!=====================================================================
6   !! History :  OPA  ! 1990-10  (G. Madec)  Original code           
7   !!                 ! 1993-02  (O. Marti)                         
8   !!                 ! 1997-02  (G. Madec)  local depth inverse computation
9   !!                 ! 1998-10  (G. Roullet, G. Madec)  free surface
10   !!   NEMO     1.0  ! 2003-07  (G. Madec)  free form, F90
11   !!            3.2  ! 2009-07  (R. Benshila) suppression of rigid-lid & FETI solver
12   !!----------------------------------------------------------------------
13#if defined key_dynspg_flt   ||   defined key_esopa 
14   !!----------------------------------------------------------------------
15   !!   'key_dynspg_flt'                              filtered free surface
16   !!----------------------------------------------------------------------
17   !!   solver_init: solver initialization
18   !!----------------------------------------------------------------------
19   USE oce             ! ocean dynamics and tracers variables
20   USE dom_oce         ! ocean space and time domain variables
21   USE zdf_oce         ! ocean vertical physics variables
22   USE sol_oce         ! solver variables
23   USE dynspg_oce      ! choice/control of key cpp for surface pressure gradient
24   USE solmat          ! matrix of the solver
25   USE in_out_manager  ! I/O manager
26   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
27   USE lib_mpp         ! MPP library
28   USE timing          ! timing
29
30   IMPLICIT NONE
31   PRIVATE solver_namelist
32
33   !!----------------------------------------------------------------------
34   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
35   !! $Id$
36   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
37   !!----------------------------------------------------------------------
38CONTAINS
39
40   SUBROUTINE solver_init( kt )
41      !!----------------------------------------------------------------------
42      !!                  ***  ROUTINE solver_init  ***
43      !!                   
44      !! ** Purpose :   Initialization of the elliptic solver
45      !!     
46      !! ** Method  :   a solver is required when using the filtered free
47      !!              surface.
48      !!
49      !! ** Action  : - c_solver_pt : nature of the gridpoint at which the solver is applied
50      !!
51      !! References : Jensen, 1986: Adv. Phys. Oceanogr. Num. Mod.,Ed. O Brien,87-110.
52      !!----------------------------------------------------------------------
53      INTEGER, INTENT(in) :: kt
54      INTEGER             ::   ios       ! Local integer output status for namelist read
55      !!
56      NAMELIST/namsol/ nn_solv, nn_sol_arp, nn_nmin, nn_nmax, nn_nmod, rn_eps, rn_resmax, rn_sor
57      !!----------------------------------------------------------------------
58      !
59      IF( nn_timing == 1 )  CALL timing_start('solver_init')
60      !
61
62      IF(lwp) THEN                  !* open elliptic solver statistics file (only on the printing processors)
63         CALL ctl_opn( numsol, 'solver.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
64      ENDIF
65      IF(lwm) THEN
66         REWIND( numnam_ref )              ! Namelist namsol in reference namelist : Elliptic solver / free surface
67         READ  ( numnam_ref, namsol, IOSTAT = ios, ERR = 901)
68901      CONTINUE
69      ENDIF
70      call mpp_bcast(ios)
71      IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsol in reference namelist', lwp )
72      IF(lwm) THEN
73         REWIND( numnam_cfg )              ! Namelist namsol in configuration namelist : Elliptic solver / free surface
74         READ  ( numnam_cfg, namsol, IOSTAT = ios, ERR = 902 )
75902      CONTINUE
76      ENDIF
77      call mpp_bcast(ios)
78      IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsol in configuration namelist', lwp )
79
80      IF(lwm) WRITE ( numond, namsol )
81
82      call solver_namelist()
83
84      IF(lwp) THEN                  !* Control print
85         WRITE(numout,*)
86         WRITE(numout,*) 'solver_init : solver to compute the surface pressure gradient'
87         WRITE(numout,*) '~~~~~~~~~~~'
88         WRITE(numout,*) '   Namelist namsol : set solver parameters'
89         WRITE(numout,*) '      type of elliptic solver            nn_solv    = ', nn_solv
90         WRITE(numout,*) '      absolute/relative (0/1) precision  nn_sol_arp = ', nn_sol_arp
91         WRITE(numout,*) '      minimum iterations for solver      nn_nmin    = ', nn_nmin
92         WRITE(numout,*) '      maximum iterations for solver      nn_nmax    = ', nn_nmax
93         WRITE(numout,*) '      frequency for test                 nn_nmod    = ', nn_nmod
94         WRITE(numout,*) '      absolute precision of solver       rn_eps     = ', rn_eps
95         WRITE(numout,*) '      absolute precision for SOR solver  rn_resmax  = ', rn_resmax
96         WRITE(numout,*) '      optimal coefficient of sor         rn_sor     = ', rn_sor
97         WRITE(numout,*)
98      ENDIF
99      eps = rn_eps
100
101      !                              ! allocate solver arrays
102      IF( .NOT. lk_agrif .OR. .NOT. ln_rstart) THEN
103         IF( sol_oce_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'solver_init : unable to allocate sol_oce arrays' )
104         gcx (:,:) = 0.e0
105         gcxb(:,:) = 0.e0
106      ENDIF
107
108      SELECT CASE( nn_solv )          !* parameter check
109      !
110      CASE ( 1 )                          ! preconditioned conjugate gradient solver
111         IF(lwp) WRITE(numout,*) '   a preconditioned conjugate gradient solver is used'
112         IF( jpr2di /= 0 .AND. jpr2dj /= 0 )   CALL ctl_stop( ' jpr2di and jpr2dj should be equal to zero' )
113         !
114      CASE ( 2 )                          ! successive-over-relaxation solver
115         IF(lwp) WRITE(numout,*) '   a successive-over-relaxation solver with extra outer halo is used'
116         IF(lwp) WRITE(numout,*) '   with jpr2di =', jpr2di, ' and  jpr2dj =', jpr2dj
117         IF( .NOT. lk_mpp .AND. jpr2di /= 0 .AND. jpr2dj /= 0 ) THEN
118             CALL ctl_stop( 'jpr2di and jpr2dj are not equal to zero',   &
119             &              'In this case the algorithm should be used only with the key_mpp_... option' )
120         ELSE
121            IF( ( ( jperio == 1 .OR. jperio == 4 .OR. jperio == 6 ) .OR. ( jpni /= 1 ) ) &
122              &  .AND. ( jpr2di /= jpr2dj ) )   CALL ctl_stop( 'jpr2di should be equal to jpr2dj' )
123         ENDIF
124         !
125      CASE DEFAULT                        ! error in parameter
126         WRITE(ctmp1,*) '          bad flag value for nn_solv = ', nn_solv
127         CALL ctl_stop( ctmp1 )
128      END SELECT
129      !
130
131      !                             !* Grid-point at which the solver is applied
132!!gm  c_solver_pt should be removed: nomore bsf, only T-point is used
133      c_solver_pt = 'T'                   ! always T-point (ssh solver only, not anymore bsf)
134
135      CALL sol_mat( kt )            !* Construction of the elliptic system matrix
136      !
137      IF( nn_timing == 1 )  CALL timing_stop('solver_init')
138      !
139   END SUBROUTINE solver_init
140
141   SUBROUTINE solver_namelist()
142     !!---------------------------------------------------------------------
143     !!                   ***  ROUTINE solver_namelist  ***
144     !!                     
145     !! ** Purpose :   Broadcast namelist variables read by procesor lwm
146     !!
147     !! ** Method  :   use lib_mpp
148     !!----------------------------------------------------------------------
149#if defined key_mpp_mpi
150      CALL mpp_bcast(nn_solv)
151      CALL mpp_bcast(nn_sol_arp)
152      CALL mpp_bcast(nn_nmin)
153      CALL mpp_bcast(nn_nmax)
154      CALL mpp_bcast(nn_nmod)
155      CALL mpp_bcast(rn_eps)
156      CALL mpp_bcast(rn_resmax)
157      CALL mpp_bcast(rn_sor)
158#endif
159   END SUBROUTINE solver_namelist
160#endif
161
162   !!======================================================================
163END MODULE solver
Note: See TracBrowser for help on using the repository browser.