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.
nemogcm.F90 in NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/SAO – NEMO

source: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/SAO/nemogcm.F90 @ 13176

Last change on this file since 13176 was 13176, checked in by smasson, 4 years ago

Extra_Halo: rewrite prtctl, supress nn_print, see #2366

  • Property svn:keywords set to Id
File size: 18.2 KB
RevLine 
[2496]1MODULE nemogcm
[2442]2   !!======================================================================
[2496]3   !!                       ***  MODULE nemogcm   ***
4   !! Ocean system   : NEMO GCM (ocean dynamics, on-line tracers, biochemistry and sea-ice)
[2442]5   !!======================================================================
[9598]6   !! History :  3.6  ! 2015-12  (A. Ryan) Original code   (from OCE/)
[7646]7   !!            4.0  ! 2016-11  (G. Madec, S. Flavoni)  domain configuration / user defined interface
[1593]8   !!----------------------------------------------------------------------
[3]9
10   !!----------------------------------------------------------------------
[7646]11   !!   nemo_gcm      : solve ocean dynamics, tracer, biogeochemistry and/or sea-ice
12   !!   nemo_init     : initialization of the NEMO system
13   !!   nemo_ctl      : initialisation of the contol print
14   !!   nemo_closefile: close remaining open files
15   !!   nemo_alloc    : dynamical allocation
[3]16   !!----------------------------------------------------------------------
[7646]17   USE step_oce       ! module used in the ocean time stepping module (step.F90)
18   USE domain         ! domain initialization   (dom_init & dom_cfg routines)
19   USE istate         ! initial state setting          (istate_init routine)
20   USE phycst         ! physical constant                  (par_cst routine)
21   USE step           ! NEMO time-stepping                 (stp     routine)
22   USE cpl_oasis3     ! OASIS3 coupling
23   USE diaobs         ! Observation diagnostics       (dia_obs_init routine)
[3625]24#if defined key_nemocice_decomp
25   USE ice_domain_size, only: nx_global, ny_global
26#endif
[7646]27   !           ! Stand Alone Observation operator modules
28   USE sao_data
29   USE sao_intp
30   !
[13176]31   USE prtctl         ! Print control
[12939]32   USE in_out_manager ! I/O manager
[7646]33   USE lib_mpp        ! distributed memory computing
34   USE mppini         ! shared/distributed memory setting (mpp_init routine)
[12586]35   USE lbcnfd  , ONLY : isendto, nsndto ! Setup of north fold exchanges
[7646]36   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
[1412]37#if defined key_iomput
[7646]38   USE xios           ! xIOserver
[1359]39#endif
[12586]40   USE halo_mng
[268]41
[2715]42   IMPLICIT NONE
[3]43   PRIVATE
44
[4829]45   PUBLIC   nemo_gcm    ! called by model.F90
[2496]46   PUBLIC   nemo_init   ! needed by AGRIF
[3764]47   PUBLIC   nemo_alloc  ! needed by TAM
[467]48
[2498]49   CHARACTER(lc) ::   cform_aaa="( /, 'AAAAAAAA', / ) "     ! flag for output listing
[1593]50
[3]51   !!----------------------------------------------------------------------
[9598]52   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
[2392]53   !! $Id$
[10068]54   !! Software governed by the CeCILL license (see ./LICENSE)
[3]55   !!----------------------------------------------------------------------
56CONTAINS
57
[4120]58   SUBROUTINE nemo_gcm
59         !!----------------------------------------------------------------------
60         !!                    ***  SUBROUTINE offline_obs_oper ***
61         !!
62         !! ** Purpose : To use NEMO components to interpolate model fields
63         !!              to observation space.
64         !!
65         !! ** Method : 1. Initialise NEMO
66         !!             2. Initialise offline obs_oper
67         !!             3. Cycle through match ups
68         !!             4. Write results to file
69         !!----------------------------------------------------------------------
[7646]70         !
71         CALL nemo_init       ! Initialise NEMO
72         !
73         CALL sao_data_init   ! Initialise Stand Alone Observation operator data
74         !
75         CALL dia_obs_init    ! Initialise obs_operator
76         !
77         CALL sao_interp      ! Interpolate to observation space
78         !
79         CALL dia_obs_wri     ! Pipe to output files
80         !
81         CALL dia_obs_dealloc ! Reset the obs_oper between
82         !
83         IF(lk_mpp)   CALL mppstop  ! Safely stop MPI (end mpp communications)
84         !
[4120]85   END SUBROUTINE nemo_gcm
[389]86
[4829]87
[2496]88   SUBROUTINE nemo_init
[389]89      !!----------------------------------------------------------------------
[2496]90      !!                     ***  ROUTINE nemo_init  ***
[389]91      !!
[2496]92      !! ** Purpose :   initialization of the NEMO GCM
[389]93      !!----------------------------------------------------------------------
[7646]94      INTEGER ::   ios, ilocal_comm   ! local integer
[5600]95      !
[13176]96      NAMELIST/namctl/ sn_cfctl, ln_timing, ln_diacfl,                                &
97         &             nn_isplt,  nn_jsplt,  nn_ictls, nn_ictle, nn_jctls, nn_jctle           
[9436]98      NAMELIST/namcfg/ ln_read_cfg, cn_domcfg, ln_closea, ln_write_cfg, cn_domcfg_out, ln_use_jattr
[3]99      !!----------------------------------------------------------------------
[1593]100      !
[5600]101      cxios_context = 'nemo'
[12586]102      nn_hls = 1
[2496]103      !
[11536]104      !                             !-------------------------------------------------!
105      !                             !     set communicator & select the local rank    !
106      !                             !  must be done as soon as possible to get narea  !
107      !                             !-------------------------------------------------!
[1593]108      !
[1412]109#if defined key_iomput
[2200]110      IF( Agrif_Root() ) THEN
[5600]111         IF( lk_oasis ) THEN
[11536]112            CALL cpl_init( "oceanx", ilocal_comm )                               ! nemo local communicator given by oasis
113            CALL xios_initialize( "not used"       , local_comm =ilocal_comm )   ! send nemo communicator to xios
[5600]114         ELSE
[11536]115            CALL xios_initialize( "for_xios_mpi_id", return_comm=ilocal_comm )   ! nemo local communicator given by xios
[5600]116         ENDIF
[2200]117      ENDIF
[11536]118      CALL mpp_start( ilocal_comm )
[532]119#else
[5600]120      IF( lk_oasis ) THEN
121         IF( Agrif_Root() ) THEN
[11536]122            CALL cpl_init( "oceanx", ilocal_comm )          ! nemo local communicator given by oasis
[5600]123         ENDIF
[11536]124         CALL mpp_start( ilocal_comm )
[5600]125      ELSE
[11536]126         CALL mpp_start( )
[2236]127      ENDIF
[532]128#endif
[11536]129      !
130      narea = mpprank + 1               ! mpprank: the rank of proc (0 --> mppsize -1 )
131      lwm = (narea == 1)                ! control of output namelists
132      !
133      !                             !---------------------------------------------------------------!
134      !                             ! Open output files, reference and configuration namelist files !
135      !                             !---------------------------------------------------------------!
136      !
137      ! open ocean.output as soon as possible to get all output prints (including errors messages)
138      IF( lwm )   CALL ctl_opn(     numout,        'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
139      ! open reference and configuration namelist files
[12377]140                  CALL load_nml( numnam_ref,        'namelist_ref',                                           -1, lwm )
141                  CALL load_nml( numnam_cfg,        'namelist_cfg',                                           -1, lwm )
[11536]142      IF( lwm )   CALL ctl_opn(     numond, 'output.namelist.dyn', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
143      ! open /dev/null file to be able to supress output write easily
[12939]144      IF( Agrif_Root() ) THEN
[11536]145                  CALL ctl_opn(     numnul,           '/dev/null', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
[12939]146#ifdef key_agrif
147      ELSE
148                  numnul = Agrif_Parent(numnul)   
149#endif
150      ENDIF
[11536]151      !
152      !                             !--------------------!
[12377]153      !                             ! Open listing units !  -> need sn_cfctl from namctl to define lwp
[11536]154      !                             !--------------------!
155      !
156      READ  ( numnam_ref, namctl, IOSTAT = ios, ERR = 901 )
157901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namctl in reference namelist' )
158      READ  ( numnam_cfg, namctl, IOSTAT = ios, ERR = 902 )
159902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namctl in configuration namelist' )
160      !
[12377]161      ! finalize the definition of namctl variables
[12939]162      IF( narea < sn_cfctl%procmin .OR. narea > sn_cfctl%procmax .OR. MOD( narea - sn_cfctl%procmin, sn_cfctl%procincr ) /= 0 )   &
163         &   CALL nemo_set_cfctl( sn_cfctl, .FALSE. )
[11536]164      !
[12377]165      lwp = (narea == 1) .OR. sn_cfctl%l_oceout    ! control of all listing output print
166      !
[11536]167      IF(lwp) THEN                      ! open listing units
[1593]168         !
[11536]169         IF( .NOT. lwm )   &            ! alreay opened for narea == 1
170            &            CALL ctl_opn( numout, 'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE., narea )
[1593]171         !
[1579]172         WRITE(numout,*)
[11536]173         WRITE(numout,*) '   CNRS - NERC - Met OFFICE - MERCATOR-ocean - CMCC'
[1593]174         WRITE(numout,*) '                       NEMO team'
[5042]175         WRITE(numout,*) '            Stand Alone Observation operator'
[10570]176         WRITE(numout,*) '                NEMO version 4.0  (2019) '
[1579]177         WRITE(numout,*)
[10570]178         WRITE(numout,*) "           ._      ._      ._      ._      ._    "
179         WRITE(numout,*) "       _.-._)`\_.-._)`\_.-._)`\_.-._)`\_.-._)`\_ "
[1579]180         WRITE(numout,*)
[10570]181         WRITE(numout,*) "           o         _,           _,             "
182         WRITE(numout,*) "            o      .' (        .-' /             "
183         WRITE(numout,*) "           o     _/..._'.    .'   /              "
184         WRITE(numout,*) "      (    o .-'`      ` '-./  _.'               "
185         WRITE(numout,*) "       )    ( o)           ;= <_         (       "
186         WRITE(numout,*) "      (      '-.,\\__ __.-;`\   '.        )      "
187         WRITE(numout,*) "       )  )       \) |`\ \)  '.   \      (   (   "
188         WRITE(numout,*) "      (  (           \_/       '-._\      )   )  "
[11536]189         WRITE(numout,*) "       )  ) jgs                     `    (   (   "
[10570]190         WRITE(numout,*) "     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "
191         WRITE(numout,*)
[1593]192         !
[7646]193         WRITE(numout,cform_aaa)                                        ! Flag AAAAAAA
194         !
[473]195      ENDIF
[11536]196      !
197      IF(lwm) WRITE( numond, namctl )
198      !
199      !                             !------------------------------------!
200      !                             !  Set global domain size parameters !
201      !                             !------------------------------------!
202      !
203      READ  ( numnam_ref, namcfg, IOSTAT = ios, ERR = 903 )
204903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namcfg in reference namelist' )
205      READ  ( numnam_cfg, namcfg, IOSTAT = ios, ERR = 904 )
206904   IF( ios >  0 )   CALL ctl_nam ( ios , 'namcfg in configuration namelist' )   
207      !
208      IF( ln_read_cfg ) THEN            ! Read sizes in domain configuration file
[12960]209         CALL domain_cfg ( cn_cfg, nn_cfg, Ni0glo, Nj0glo, jpkglo, jperio )
[11536]210      ELSE                              ! user-defined namelist
[12960]211         CALL usr_def_nam( cn_cfg, nn_cfg, Ni0glo, Nj0glo, jpkglo, jperio )
[11536]212      ENDIF
213      !
214      IF(lwm)   WRITE( numond, namcfg )
215      !
216      !                             !-----------------------------------------!
217      !                             ! mpp parameters and domain decomposition !
218      !                             !-----------------------------------------!
219      CALL mpp_init
[2715]220
[12586]221      CALL halo_mng_init()
[7646]222      ! Now we know the dimensions of the grid and numout has been set: we can allocate arrays
[2715]223      CALL nemo_alloc()
224
[2496]225      !                             !-------------------------------!
226      !                             !  NEMO general initialization  !
227      !                             !-------------------------------!
[473]228
[9436]229      CALL nemo_ctl                          ! Control prints
[2382]230      !
[9436]231      !                                         ! General initialization
232      IF( ln_timing    )   CALL timing_init     ! timing
233      IF( ln_timing    )   CALL timing_start( 'nemo_init')
[3294]234      !
[9019]235                           CALL phy_cst            ! Physical constants
236                           CALL eos_init           ! Equation of state
[12377]237                           CALL dom_init( Nbb, Nnn, Naa, 'SAO')    ! Domain
[413]238
[3294]239
[12377]240      IF( sn_cfctl%l_prtctl )   &
241         &                 CALL prt_ctl_init       ! Print control
[2027]242
[12377]243                           CALL istate_init        ! ocean initial state (Dynamics and tracers)
[2496]244   END SUBROUTINE nemo_init
[467]245
246
[2496]247   SUBROUTINE nemo_ctl
[467]248      !!----------------------------------------------------------------------
[2496]249      !!                     ***  ROUTINE nemo_ctl  ***
[467]250      !!
[3764]251      !! ** Purpose :   control print setting
[467]252      !!
[12377]253      !! ** Method  : - print namctl and namcfg information and check some consistencies
[467]254      !!----------------------------------------------------------------------
[2442]255      !
[2496]256      IF(lwp) THEN                  ! control print
[531]257         WRITE(numout,*)
[7646]258         WRITE(numout,*) 'nemo_ctl: Control prints'
[9436]259         WRITE(numout,*) '~~~~~~~~'
[1593]260         WRITE(numout,*) '   Namelist namctl'
[10570]261         WRITE(numout,*) '                              sn_cfctl%l_runstat = ', sn_cfctl%l_runstat
262         WRITE(numout,*) '                              sn_cfctl%l_trcstat = ', sn_cfctl%l_trcstat
263         WRITE(numout,*) '                              sn_cfctl%l_oceout  = ', sn_cfctl%l_oceout
264         WRITE(numout,*) '                              sn_cfctl%l_layout  = ', sn_cfctl%l_layout
[12377]265         WRITE(numout,*) '                              sn_cfctl%l_prtctl  = ', sn_cfctl%l_prtctl
266         WRITE(numout,*) '                              sn_cfctl%l_prttrc  = ', sn_cfctl%l_prttrc
267         WRITE(numout,*) '                              sn_cfctl%l_oasout  = ', sn_cfctl%l_oasout
[10570]268         WRITE(numout,*) '                              sn_cfctl%procmin   = ', sn_cfctl%procmin 
269         WRITE(numout,*) '                              sn_cfctl%procmax   = ', sn_cfctl%procmax 
270         WRITE(numout,*) '                              sn_cfctl%procincr  = ', sn_cfctl%procincr 
271         WRITE(numout,*) '                              sn_cfctl%ptimincr  = ', sn_cfctl%ptimincr 
[9019]272         WRITE(numout,*) '      timing by routine               ln_timing  = ', ln_timing
273         WRITE(numout,*) '      CFL diagnostics                 ln_diacfl  = ', ln_diacfl
[531]274      ENDIF
[2442]275      !
[13176]276      IF( .NOT.ln_read_cfg )   ln_closea = .false.   ! dealing possible only with a domcfg file
[4829]277      IF(lwp) THEN                  ! control print
278         WRITE(numout,*)
279         WRITE(numout,*) '   Namelist namcfg'
[7646]280         WRITE(numout,*) '      read domain configuration file                ln_read_cfg      = ', ln_read_cfg
281         WRITE(numout,*) '         filename to be read                           cn_domcfg     = ', TRIM(cn_domcfg)
[9436]282         WRITE(numout,*) '         keep closed seas in the domain (if exist)     ln_closea     = ', ln_closea
[10570]283         WRITE(numout,*) '      create a configuration definition file        ln_write_cfg     = ', ln_write_cfg
[7646]284         WRITE(numout,*) '         filename to be written                        cn_domcfg_out = ', TRIM(cn_domcfg_out)
285         WRITE(numout,*) '      use file attribute if exists as i/p j-start   ln_use_jattr     = ', ln_use_jattr
[4829]286      ENDIF
[9436]287      !
[10570]288      IF( 1._wp /= SIGN(1._wp,-0._wp)  )   CALL ctl_stop( 'nemo_ctl: The intrinsec SIGN function follows f2003 standard.',  &
289         &                                                'Compile with key_nosignedzero enabled:',   &
290         &                                                '--> add -Dkey_nosignedzero to the definition of %CPP in your arch file' )
[3764]291      !
[2496]292   END SUBROUTINE nemo_ctl
[467]293
294
[2496]295   SUBROUTINE nemo_closefile
[467]296      !!----------------------------------------------------------------------
[2496]297      !!                     ***  ROUTINE nemo_closefile  ***
[467]298      !!
299      !! ** Purpose :   Close the files
300      !!----------------------------------------------------------------------
[1593]301      !
302      IF( lk_mpp )   CALL mppsync
303      !
[1685]304      CALL iom_close                                 ! close all input/output files managed by iom_*
[1593]305      !
[4829]306      IF( numstp          /= -1 )   CLOSE( numstp          )   ! time-step file
[9019]307      IF( numrun          /= -1 )   CLOSE( numrun          )   ! run statistics file
[4829]308      IF( lwm.AND.numond  /= -1 )   CLOSE( numond          )   ! oce output namelist
309      IF( lwm.AND.numoni  /= -1 )   CLOSE( numoni          )   ! ice output namelist
310      IF( numevo_ice      /= -1 )   CLOSE( numevo_ice      )   ! ice variables (temp. evolution)
311      IF( numout          /=  6 )   CLOSE( numout          )   ! standard model output file
312      IF( numdct_vol      /= -1 )   CLOSE( numdct_vol      )   ! volume transports
313      IF( numdct_heat     /= -1 )   CLOSE( numdct_heat     )   ! heat transports
314      IF( numdct_salt     /= -1 )   CLOSE( numdct_salt     )   ! salt transports
[1593]315      !
[2442]316      numout = 6                                     ! redefine numout in case it is used after this point...
317      !
[2496]318   END SUBROUTINE nemo_closefile
[467]319
[2715]320
321   SUBROUTINE nemo_alloc
322      !!----------------------------------------------------------------------
323      !!                     ***  ROUTINE nemo_alloc  ***
324      !!
325      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
326      !!
327      !! ** Method  :
328      !!----------------------------------------------------------------------
329      USE diawri    , ONLY: dia_wri_alloc
330      USE dom_oce   , ONLY: dom_oce_alloc
331      !
332      INTEGER :: ierr
333      !!----------------------------------------------------------------------
334      !
[3764]335      ierr =        oce_alloc       ()          ! ocean
[2715]336      ierr = ierr + dia_wri_alloc   ()
337      ierr = ierr + dom_oce_alloc   ()          ! ocean domain
338      !
[10425]339      CALL mpp_sum( 'nemogcm', ierr )
[2715]340      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'nemo_alloc : unable to allocate standard ocean arrays' )
341      !
342   END SUBROUTINE nemo_alloc
343
[12939]344   SUBROUTINE nemo_set_cfctl(sn_cfctl, setto )
[10570]345      !!----------------------------------------------------------------------
346      !!                     ***  ROUTINE nemo_set_cfctl  ***
347      !!
348      !! ** Purpose :   Set elements of the output control structure to setto.
349      !!
350      !! ** Method  :   Note this routine can be used to switch on/off some
[12939]351      !!                types of output for selected areas.
[10570]352      !!----------------------------------------------------------------------
[12939]353      TYPE(sn_ctl), INTENT(inout) :: sn_cfctl
354      LOGICAL     , INTENT(in   ) :: setto
[10570]355      !!----------------------------------------------------------------------
[12939]356      sn_cfctl%l_runstat = setto
357      sn_cfctl%l_trcstat = setto
[10570]358      sn_cfctl%l_oceout  = setto
359      sn_cfctl%l_layout  = setto
[12377]360      sn_cfctl%l_prtctl  = setto
361      sn_cfctl%l_prttrc  = setto
362      sn_cfctl%l_oasout  = setto
[10570]363   END SUBROUTINE nemo_set_cfctl
364
[3]365   !!======================================================================
[2496]366END MODULE nemogcm
[4829]367
Note: See TracBrowser for help on using the repository browser.