[3324] | 1 | MODULE nemogcm |
---|
| 2 | !!====================================================================== |
---|
| 3 | !! *** MODULE nemogcm *** |
---|
[7646] | 4 | !! StandAlone Surface module : surface fluxes + sea-ice + iceberg floats |
---|
[3324] | 5 | !!====================================================================== |
---|
[7646] | 6 | !! History : 3.6 ! 2011-11 (S. Alderson, G. Madec) original code |
---|
| 7 | !! - ! 2013-06 (I. Epicoco, S. Mocavero, CMCC) nemo_northcomms: setup avoiding MPI communication |
---|
| 8 | !! - ! 2014-12 (G. Madec) remove KPP scheme and cross-land advection (cla) |
---|
| 9 | !! 4.0 ! 2016-10 (G. Madec, S. Flavoni) domain configuration / user defined interface |
---|
[3324] | 10 | !!---------------------------------------------------------------------- |
---|
| 11 | |
---|
| 12 | !!---------------------------------------------------------------------- |
---|
[7646] | 13 | !! nemo_gcm : solve ocean dynamics, tracer, biogeochemistry and/or sea-ice |
---|
| 14 | !! nemo_init : initialization of the NEMO system |
---|
| 15 | !! nemo_ctl : initialisation of the contol print |
---|
| 16 | !! nemo_closefile: close remaining open files |
---|
| 17 | !! nemo_alloc : dynamical allocation |
---|
[3324] | 18 | !!---------------------------------------------------------------------- |
---|
[7646] | 19 | USE step_oce ! module used in the ocean time stepping module |
---|
| 20 | USE sbc_oce ! surface boundary condition: ocean |
---|
| 21 | USE phycst ! physical constant (par_cst routine) |
---|
| 22 | USE domain ! domain initialization (dom_init & dom_cfg routines) |
---|
[9200] | 23 | USE closea ! treatment of closed seas (for ln_closea) |
---|
[7646] | 24 | USE usrdef_nam ! user defined configuration |
---|
| 25 | USE daymod ! calendar |
---|
[8583] | 26 | USE restart ! open restart file |
---|
[7646] | 27 | USE step ! NEMO time-stepping (stp routine) |
---|
| 28 | USE cpl_oasis3 ! |
---|
| 29 | USE sbcssm ! |
---|
| 30 | USE icbini ! handle bergs, initialisation |
---|
| 31 | USE icbstp ! handle bergs, calving, themodynamics and transport |
---|
[9019] | 32 | USE bdyini ! open boundary cond. setting (bdy_init routine). mandatory for sea-ice |
---|
| 33 | USE bdydta ! open boundary cond. setting (bdy_dta_init routine). mandatory for sea-ice |
---|
[12377] | 34 | USE diu_layers ! diurnal bulk SST and coolskin |
---|
| 35 | USE step_diu ! diurnal bulk SST timestepping (called from here if run offline) |
---|
[7646] | 36 | ! |
---|
[12939] | 37 | USE in_out_manager ! I/O manager |
---|
[7646] | 38 | USE lib_mpp ! distributed memory computing |
---|
| 39 | USE mppini ! shared/distributed memory setting (mpp_init routine) |
---|
[12586] | 40 | USE lbcnfd , ONLY : isendto, nsndto ! Setup of north fold exchanges |
---|
[7646] | 41 | USE lib_fortran ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined) |
---|
[3324] | 42 | #if defined key_iomput |
---|
[7646] | 43 | USE xios ! xIOserver |
---|
[3324] | 44 | #endif |
---|
[9781] | 45 | #if defined key_agrif && defined key_si3 |
---|
| 46 | USE agrif_ice_update ! ice update |
---|
| 47 | #endif |
---|
[12586] | 48 | USE halo_mng |
---|
[3324] | 49 | |
---|
| 50 | IMPLICIT NONE |
---|
| 51 | PRIVATE |
---|
| 52 | |
---|
| 53 | PUBLIC nemo_gcm ! called by model.F90 |
---|
| 54 | PUBLIC nemo_init ! needed by AGRIF |
---|
| 55 | |
---|
| 56 | CHARACTER(lc) :: cform_aaa="( /, 'AAAAAAAA', / ) " ! flag for output listing |
---|
| 57 | |
---|
[12377] | 58 | #if defined key_mpp_mpi |
---|
| 59 | INCLUDE 'mpif.h' |
---|
| 60 | #endif |
---|
| 61 | |
---|
[3324] | 62 | !!---------------------------------------------------------------------- |
---|
[10068] | 63 | !! NEMO/SAS 4.0 , NEMO Consortium (2018) |
---|
[5215] | 64 | !! $Id$ |
---|
[10068] | 65 | !! Software governed by the CeCILL license (see ./LICENSE) |
---|
[3324] | 66 | !!---------------------------------------------------------------------- |
---|
| 67 | CONTAINS |
---|
| 68 | |
---|
| 69 | SUBROUTINE nemo_gcm |
---|
| 70 | !!---------------------------------------------------------------------- |
---|
| 71 | !! *** ROUTINE nemo_gcm *** |
---|
| 72 | !! |
---|
[7646] | 73 | !! ** Purpose : NEMO solves the primitive equations on an orthogonal |
---|
[3324] | 74 | !! curvilinear mesh on the sphere. |
---|
| 75 | !! |
---|
| 76 | !! ** Method : - model general initialization |
---|
| 77 | !! - launch the time-stepping (stp routine) |
---|
| 78 | !! - finalize the run by closing files and communications |
---|
| 79 | !! |
---|
| 80 | !! References : Madec, Delecluse, Imbard, and Levy, 1997: internal report, IPSL. |
---|
| 81 | !! Madec, 2008, internal report, IPSL. |
---|
| 82 | !!---------------------------------------------------------------------- |
---|
[7646] | 83 | INTEGER :: istp ! time step index |
---|
[3324] | 84 | !!---------------------------------------------------------------------- |
---|
| 85 | ! |
---|
| 86 | #if defined key_agrif |
---|
[9213] | 87 | CALL Agrif_Init_Grids() ! AGRIF: set the meshes |
---|
[3324] | 88 | #endif |
---|
| 89 | ! !-----------------------! |
---|
| 90 | CALL nemo_init !== Initialisations ==! |
---|
| 91 | ! !-----------------------! |
---|
| 92 | #if defined key_agrif |
---|
[12377] | 93 | Kbb_a = Nbb; Kmm_a = Nnn; Krhs_a = Nrhs ! agrif_oce module copies of time level indices |
---|
[5407] | 94 | CALL Agrif_Declare_Var_dom ! AGRIF: set the meshes for DOM |
---|
| 95 | CALL Agrif_Declare_Var ! " " " " " DYN/TRA |
---|
| 96 | # if defined key_top |
---|
| 97 | CALL Agrif_Declare_Var_top ! " " " " " TOP |
---|
| 98 | # endif |
---|
[9570] | 99 | # if defined key_si3 |
---|
[9611] | 100 | CALL Agrif_Declare_Var_ice ! " " " " " Sea ice |
---|
[7646] | 101 | # endif |
---|
[3324] | 102 | #endif |
---|
| 103 | ! check that all process are still there... If some process have an error, |
---|
| 104 | ! they will never enter in step and other processes will wait until the end of the cpu time! |
---|
[10425] | 105 | CALL mpp_max( 'nemogcm', nstop ) |
---|
[3324] | 106 | |
---|
| 107 | IF(lwp) WRITE(numout,cform_aaa) ! Flag AAAAAAA |
---|
| 108 | |
---|
| 109 | ! !-----------------------! |
---|
| 110 | ! !== time stepping ==! |
---|
| 111 | ! !-----------------------! |
---|
| 112 | istp = nit000 |
---|
[9213] | 113 | ! |
---|
[7646] | 114 | #if defined key_agrif |
---|
[9213] | 115 | ! !== AGRIF time-stepping ==! |
---|
[7646] | 116 | CALL Agrif_Regrid() |
---|
[9213] | 117 | ! |
---|
[9781] | 118 | #if defined key_si3 |
---|
| 119 | ! Recursive update from highest nested level to lowest: |
---|
[12377] | 120 | Kbb_a = Nbb; Kmm_a = Nnn; Krhs_a = Nrhs ! agrif_oce module copies of time level indices |
---|
[9781] | 121 | CALL Agrif_step_child_adj(Agrif_update_ice) |
---|
| 122 | #endif |
---|
| 123 | ! |
---|
[9213] | 124 | DO WHILE( istp <= nitend .AND. nstop == 0 ) |
---|
| 125 | CALL stp |
---|
| 126 | istp = istp + 1 |
---|
| 127 | END DO |
---|
| 128 | ! |
---|
[3324] | 129 | #else |
---|
[9213] | 130 | ! |
---|
| 131 | IF( .NOT.ln_diurnal_only ) THEN !== Standard time-stepping ==! |
---|
| 132 | ! |
---|
| 133 | DO WHILE( istp <= nitend .AND. nstop == 0 ) |
---|
[12377] | 134 | #if defined key_mpp_mpi |
---|
| 135 | ncom_stp = istp |
---|
| 136 | IF ( istp == ( nit000 + 1 ) ) elapsed_time = MPI_Wtime() |
---|
| 137 | IF ( istp == nitend ) elapsed_time = MPI_Wtime() - elapsed_time |
---|
| 138 | #endif |
---|
[9213] | 139 | CALL stp ( istp ) |
---|
| 140 | istp = istp + 1 |
---|
[7646] | 141 | END DO |
---|
[9213] | 142 | ! |
---|
| 143 | ELSE !== diurnal SST time-steeping only ==! |
---|
| 144 | ! |
---|
| 145 | DO WHILE( istp <= nitend .AND. nstop == 0 ) |
---|
| 146 | CALL stp_diurnal( istp ) ! time step only the diurnal SST |
---|
| 147 | istp = istp + 1 |
---|
| 148 | END DO |
---|
| 149 | ! |
---|
| 150 | ENDIF |
---|
[5407] | 151 | ! |
---|
[9213] | 152 | #endif |
---|
| 153 | ! |
---|
[5407] | 154 | IF( ln_icebergs ) CALL icb_end( nitend ) |
---|
| 155 | |
---|
[3324] | 156 | ! !------------------------! |
---|
| 157 | ! !== finalize the run ==! |
---|
| 158 | ! !------------------------! |
---|
[7646] | 159 | IF(lwp) WRITE(numout,cform_aaa) ! Flag AAAAAAA |
---|
[3324] | 160 | ! |
---|
[7646] | 161 | IF( nstop /= 0 .AND. lwp ) THEN ! error print |
---|
[11536] | 162 | WRITE(ctmp1,*) ' ==>>> nemo_gcm: a total of ', nstop, ' errors have been found' |
---|
[12939] | 163 | IF( ngrdstop > 0 ) THEN |
---|
| 164 | WRITE(ctmp9,'(i2)') ngrdstop |
---|
| 165 | WRITE(ctmp2,*) ' ==>>> Error detected in Agrif grid '//TRIM(ctmp9) |
---|
| 166 | WRITE(ctmp3,*) ' ==>>> look for error messages in '//TRIM(ctmp9)//'_ocean_output* files' |
---|
| 167 | CALL ctl_stop( ctmp1, ctmp2, ctmp3 ) |
---|
| 168 | ELSE |
---|
| 169 | CALL ctl_stop( ctmp1 ) |
---|
| 170 | ENDIF |
---|
[3324] | 171 | ENDIF |
---|
| 172 | ! |
---|
[9019] | 173 | IF( ln_timing ) CALL timing_finalize |
---|
[3324] | 174 | ! |
---|
| 175 | CALL nemo_closefile |
---|
[5407] | 176 | ! |
---|
[3769] | 177 | #if defined key_iomput |
---|
[9213] | 178 | CALL xios_finalize ! end mpp communications with xios |
---|
| 179 | IF( lk_oasis ) CALL cpl_finalize ! end coupling and mpp communications with OASIS |
---|
[3769] | 180 | #else |
---|
[9213] | 181 | IF ( lk_oasis ) THEN ; CALL cpl_finalize ! end coupling and mpp communications with OASIS |
---|
[11536] | 182 | ELSEIF( lk_mpp ) THEN ; CALL mppstop ! end mpp communications |
---|
[5407] | 183 | ENDIF |
---|
[3769] | 184 | #endif |
---|
[3324] | 185 | ! |
---|
[11229] | 186 | IF(lwm) THEN |
---|
| 187 | IF( nstop == 0 ) THEN ; STOP 0 |
---|
[11536] | 188 | ELSE ; STOP 123 |
---|
[11229] | 189 | ENDIF |
---|
| 190 | ENDIF |
---|
| 191 | ! |
---|
[3324] | 192 | END SUBROUTINE nemo_gcm |
---|
| 193 | |
---|
| 194 | |
---|
| 195 | SUBROUTINE nemo_init |
---|
| 196 | !!---------------------------------------------------------------------- |
---|
| 197 | !! *** ROUTINE nemo_init *** |
---|
| 198 | !! |
---|
| 199 | !! ** Purpose : initialization of the NEMO GCM |
---|
| 200 | !!---------------------------------------------------------------------- |
---|
[11536] | 201 | INTEGER :: ios, ilocal_comm ! local integers |
---|
[9213] | 202 | !! |
---|
[12377] | 203 | NAMELIST/namctl/ sn_cfctl, nn_print, nn_ictls, nn_ictle, & |
---|
[10570] | 204 | & nn_isplt , nn_jsplt, nn_jctls, nn_jctle, & |
---|
[9019] | 205 | & ln_timing, ln_diacfl |
---|
[9213] | 206 | NAMELIST/namcfg/ ln_read_cfg, cn_domcfg, ln_closea, ln_write_cfg, cn_domcfg_out, ln_use_jattr |
---|
[3324] | 207 | !!---------------------------------------------------------------------- |
---|
[5407] | 208 | ! |
---|
[11536] | 209 | IF( lk_oasis ) THEN ; cxios_context = 'sas' |
---|
| 210 | ELSE ; cxios_context = 'nemo' |
---|
[7646] | 211 | ENDIF |
---|
[12586] | 212 | nn_hls = 1 |
---|
[7646] | 213 | ! |
---|
[11536] | 214 | ! !-------------------------------------------------! |
---|
| 215 | ! ! set communicator & select the local rank ! |
---|
| 216 | ! ! must be done as soon as possible to get narea ! |
---|
| 217 | ! !-------------------------------------------------! |
---|
[7646] | 218 | ! |
---|
[3324] | 219 | #if defined key_iomput |
---|
| 220 | IF( Agrif_Root() ) THEN |
---|
[5407] | 221 | IF( lk_oasis ) THEN |
---|
[11536] | 222 | CALL cpl_init( "sas", ilocal_comm ) ! nemo local communicator given by oasis |
---|
| 223 | CALL xios_initialize( "not used",local_comm=ilocal_comm ) ! send nemo communicator to xios |
---|
[5407] | 224 | ELSE |
---|
[7646] | 225 | CALL xios_initialize( "for_xios_mpi_id",return_comm=ilocal_comm ) ! nemo local communicator given by xios |
---|
[5407] | 226 | ENDIF |
---|
[3324] | 227 | ENDIF |
---|
[11536] | 228 | CALL mpp_start( ilocal_comm ) |
---|
[3324] | 229 | #else |
---|
[5407] | 230 | IF( lk_oasis ) THEN |
---|
| 231 | IF( Agrif_Root() ) THEN |
---|
[11536] | 232 | CALL cpl_init( "sas", ilocal_comm ) ! nemo local communicator given by oasis |
---|
[5407] | 233 | ENDIF |
---|
[11536] | 234 | CALL mpp_start( ilocal_comm ) |
---|
[5407] | 235 | ELSE |
---|
[11536] | 236 | CALL mpp_start( ) |
---|
[5407] | 237 | ENDIF |
---|
[3324] | 238 | #endif |
---|
[11536] | 239 | ! |
---|
| 240 | narea = mpprank + 1 ! mpprank: the rank of proc (0 --> mppsize -1 ) |
---|
| 241 | lwm = (narea == 1) ! control of output namelists |
---|
| 242 | ! |
---|
| 243 | ! !---------------------------------------------------------------! |
---|
| 244 | ! ! Open output files, reference and configuration namelist files ! |
---|
| 245 | ! !---------------------------------------------------------------! |
---|
| 246 | ! |
---|
| 247 | ! open ocean.output as soon as possible to get all output prints (including errors messages) |
---|
| 248 | IF( lk_oasis ) THEN |
---|
[12377] | 249 | IF( lwm ) CALL ctl_opn( numout, 'sas.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. ) |
---|
[11536] | 250 | ! open reference and configuration namelist files |
---|
[12377] | 251 | CALL load_nml( numnam_ref, 'namelist_sas_ref', -1, lwm ) |
---|
| 252 | CALL load_nml( numnam_cfg, 'namelist_sas_cfg', -1, lwm ) |
---|
| 253 | IF( lwm ) CALL ctl_opn( numond, 'output.namelist_sas.dyn', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. ) |
---|
[10570] | 254 | ELSE |
---|
[12377] | 255 | IF( lwm ) CALL ctl_opn( numout, 'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. ) |
---|
[11536] | 256 | ! open reference and configuration namelist files |
---|
[12377] | 257 | CALL load_nml( numnam_ref, 'namelist_ref', -1, lwm ) |
---|
| 258 | CALL load_nml( numnam_cfg, 'namelist_cfg', -1, lwm ) |
---|
| 259 | IF( lwm ) CALL ctl_opn( numond, 'output.namelist.dyn', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. ) |
---|
[10570] | 260 | ENDIF |
---|
[11536] | 261 | ! open /dev/null file to be able to supress output write easily |
---|
[12939] | 262 | IF( Agrif_Root() ) THEN |
---|
[11536] | 263 | CALL ctl_opn( numnul, '/dev/null', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. ) |
---|
[12939] | 264 | #ifdef key_agrif |
---|
| 265 | ELSE |
---|
| 266 | numnul = Agrif_Parent(numnul) |
---|
| 267 | #endif |
---|
| 268 | ENDIF |
---|
[11536] | 269 | ! |
---|
| 270 | ! !--------------------! |
---|
[12377] | 271 | ! ! Open listing units ! -> need sn_cfctl from namctl to define lwp |
---|
[11536] | 272 | ! !--------------------! |
---|
| 273 | ! |
---|
| 274 | READ ( numnam_ref, namctl, IOSTAT = ios, ERR = 901 ) |
---|
| 275 | 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namctl in reference namelist' ) |
---|
| 276 | READ ( numnam_cfg, namctl, IOSTAT = ios, ERR = 902 ) |
---|
| 277 | 902 IF( ios > 0 ) CALL ctl_nam ( ios , 'namctl in configuration namelist' ) |
---|
| 278 | ! |
---|
[12377] | 279 | ! finalize the definition of namctl variables |
---|
[12939] | 280 | IF( narea < sn_cfctl%procmin .OR. narea > sn_cfctl%procmax .OR. MOD( narea - sn_cfctl%procmin, sn_cfctl%procincr ) /= 0 ) & |
---|
| 281 | & CALL nemo_set_cfctl( sn_cfctl, .FALSE. ) |
---|
[11536] | 282 | ! |
---|
[12377] | 283 | lwp = (narea == 1) .OR. sn_cfctl%l_oceout ! control of all listing output print |
---|
| 284 | ! |
---|
[11536] | 285 | IF(lwp) THEN ! open listing units |
---|
[3324] | 286 | ! |
---|
[11536] | 287 | IF( .NOT. lwm ) THEN ! alreay opened for narea == 1 |
---|
| 288 | IF(lk_oasis) THEN ; CALL ctl_opn( numout, 'sas.output','REPLACE','FORMATTED','SEQUENTIAL',-1,-1, .FALSE., narea ) |
---|
| 289 | ELSE ; CALL ctl_opn( numout, 'ocean.output','REPLACE','FORMATTED','SEQUENTIAL',-1,-1, .FALSE., narea ) |
---|
| 290 | ENDIF |
---|
[5407] | 291 | ENDIF |
---|
[3324] | 292 | ! |
---|
| 293 | WRITE(numout,*) |
---|
[11536] | 294 | WRITE(numout,*) ' CNRS - NERC - Met OFFICE - MERCATOR-ocean - CMCC' |
---|
[3324] | 295 | WRITE(numout,*) ' NEMO team' |
---|
| 296 | WRITE(numout,*) ' Ocean General Circulation Model' |
---|
[10570] | 297 | WRITE(numout,*) ' NEMO version 4.0 (2019) ' |
---|
[3331] | 298 | WRITE(numout,*) ' StandAlone Surface version (SAS) ' |
---|
[10570] | 299 | WRITE(numout,*) " ._ ._ ._ ._ ._ " |
---|
| 300 | WRITE(numout,*) " _.-._)`\_.-._)`\_.-._)`\_.-._)`\_.-._)`\_ " |
---|
[3324] | 301 | WRITE(numout,*) |
---|
[10570] | 302 | WRITE(numout,*) " o _, _, " |
---|
| 303 | WRITE(numout,*) " o .' ( .-' / " |
---|
| 304 | WRITE(numout,*) " o _/..._'. .' / " |
---|
| 305 | WRITE(numout,*) " ( o .-'` ` '-./ _.' " |
---|
| 306 | WRITE(numout,*) " ) ( o) ;= <_ ( " |
---|
| 307 | WRITE(numout,*) " ( '-.,\\__ __.-;`\ '. ) " |
---|
| 308 | WRITE(numout,*) " ) ) \) |`\ \) '. \ ( ( " |
---|
| 309 | WRITE(numout,*) " ( ( \_/ '-._\ ) ) " |
---|
[11229] | 310 | WRITE(numout,*) " ) ) jgs ` ( ( " |
---|
[10570] | 311 | WRITE(numout,*) " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ " |
---|
[3324] | 312 | WRITE(numout,*) |
---|
[7646] | 313 | WRITE(numout,*) |
---|
[3324] | 314 | ! |
---|
[7646] | 315 | WRITE(numout,cform_aaa) ! Flag AAAAAAA |
---|
| 316 | ! |
---|
[3324] | 317 | ENDIF |
---|
[10459] | 318 | ! |
---|
[11536] | 319 | IF(lwm) WRITE( numond, namctl ) |
---|
| 320 | ! |
---|
| 321 | ! !------------------------------------! |
---|
| 322 | ! ! Set global domain size parameters ! |
---|
| 323 | ! !------------------------------------! |
---|
| 324 | ! |
---|
| 325 | READ ( numnam_ref, namcfg, IOSTAT = ios, ERR = 903 ) |
---|
| 326 | 903 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namcfg in reference namelist' ) |
---|
| 327 | READ ( numnam_cfg, namcfg, IOSTAT = ios, ERR = 904 ) |
---|
| 328 | 904 IF( ios > 0 ) CALL ctl_nam ( ios , 'namcfg in configuration namelist' ) |
---|
| 329 | ! |
---|
| 330 | IF( ln_read_cfg ) THEN ! Read sizes in domain configuration file |
---|
| 331 | CALL domain_cfg ( cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio ) |
---|
| 332 | ELSE ! user-defined namelist |
---|
| 333 | CALL usr_def_nam( cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio ) |
---|
| 334 | ENDIF |
---|
| 335 | ! |
---|
| 336 | IF(lwm) WRITE( numond, namcfg ) |
---|
| 337 | ! |
---|
| 338 | ! !-----------------------------------------! |
---|
| 339 | ! ! mpp parameters and domain decomposition ! |
---|
| 340 | ! !-----------------------------------------! |
---|
| 341 | CALL mpp_init |
---|
[3324] | 342 | |
---|
[12586] | 343 | CALL halo_mng_init() |
---|
[7646] | 344 | ! Now we know the dimensions of the grid and numout has been set: we can allocate arrays |
---|
[3324] | 345 | CALL nemo_alloc() |
---|
[9213] | 346 | |
---|
[12377] | 347 | ! Initialise time level indices |
---|
| 348 | Nbb = 1; Nnn = 2; Naa = 3; Nrhs = Naa |
---|
| 349 | |
---|
[3324] | 350 | ! !-------------------------------! |
---|
| 351 | ! ! NEMO general initialization ! |
---|
| 352 | ! !-------------------------------! |
---|
| 353 | |
---|
[7646] | 354 | CALL nemo_ctl ! Control prints |
---|
[3324] | 355 | ! |
---|
[9213] | 356 | ! ! General initialization |
---|
| 357 | IF( ln_timing ) CALL timing_init ! timing |
---|
| 358 | IF( ln_timing ) CALL timing_start( 'nemo_init') |
---|
[3324] | 359 | |
---|
[9213] | 360 | CALL phy_cst ! Physical constants |
---|
| 361 | CALL eos_init ! Equation of seawater |
---|
[12377] | 362 | CALL dom_init( Nbb, Nnn, Naa, 'SAS') ! Domain |
---|
| 363 | IF( sn_cfctl%l_prtctl ) & |
---|
| 364 | & CALL prt_ctl_init ! Print control |
---|
[9213] | 365 | |
---|
| 366 | CALL day_init ! model calendar (using both namelist and restart infos) |
---|
| 367 | IF( ln_rstart ) CALL rst_read_open |
---|
[3324] | 368 | |
---|
[9213] | 369 | ! ! external forcing |
---|
[12377] | 370 | CALL sbc_init( Nbb, Nnn, Naa ) ! Forcings : surface module |
---|
[3324] | 371 | |
---|
[9019] | 372 | ! ==> clem: open boundaries init. is mandatory for sea-ice because ice BDY is not decoupled from |
---|
[5510] | 373 | ! the environment of ocean BDY. Therefore bdy is called in both OPA and SAS modules. |
---|
| 374 | ! This is not clean and should be changed in the future. |
---|
[9019] | 375 | CALL bdy_init |
---|
[5510] | 376 | ! ==> |
---|
[12489] | 377 | CALL icb_init( rn_Dt, nit000) ! initialise icebergs instance |
---|
[3324] | 378 | ! |
---|
[9213] | 379 | IF(lwp) WRITE(numout,cform_aaa) ! Flag AAAAAAA |
---|
| 380 | ! |
---|
| 381 | IF( ln_timing ) CALL timing_stop( 'nemo_init') |
---|
| 382 | ! |
---|
[3324] | 383 | END SUBROUTINE nemo_init |
---|
| 384 | |
---|
| 385 | |
---|
| 386 | SUBROUTINE nemo_ctl |
---|
| 387 | !!---------------------------------------------------------------------- |
---|
| 388 | !! *** ROUTINE nemo_ctl *** |
---|
| 389 | !! |
---|
[9213] | 390 | !! ** Purpose : control print setting |
---|
[3324] | 391 | !! |
---|
[12377] | 392 | !! ** Method : - print namctl and namcfg information and check some consistencies |
---|
[3324] | 393 | !!---------------------------------------------------------------------- |
---|
| 394 | ! |
---|
| 395 | IF(lwp) THEN ! control print |
---|
| 396 | WRITE(numout,*) |
---|
[7646] | 397 | WRITE(numout,*) 'nemo_ctl: Control prints' |
---|
[9213] | 398 | WRITE(numout,*) '~~~~~~~~' |
---|
[3324] | 399 | WRITE(numout,*) ' Namelist namctl' |
---|
[10570] | 400 | WRITE(numout,*) ' sn_cfctl%l_runstat = ', sn_cfctl%l_runstat |
---|
| 401 | WRITE(numout,*) ' sn_cfctl%l_trcstat = ', sn_cfctl%l_trcstat |
---|
| 402 | WRITE(numout,*) ' sn_cfctl%l_oceout = ', sn_cfctl%l_oceout |
---|
| 403 | WRITE(numout,*) ' sn_cfctl%l_layout = ', sn_cfctl%l_layout |
---|
[12377] | 404 | WRITE(numout,*) ' sn_cfctl%l_prtctl = ', sn_cfctl%l_prtctl |
---|
| 405 | WRITE(numout,*) ' sn_cfctl%l_prttrc = ', sn_cfctl%l_prttrc |
---|
| 406 | WRITE(numout,*) ' sn_cfctl%l_oasout = ', sn_cfctl%l_oasout |
---|
[10570] | 407 | WRITE(numout,*) ' sn_cfctl%procmin = ', sn_cfctl%procmin |
---|
| 408 | WRITE(numout,*) ' sn_cfctl%procmax = ', sn_cfctl%procmax |
---|
| 409 | WRITE(numout,*) ' sn_cfctl%procincr = ', sn_cfctl%procincr |
---|
| 410 | WRITE(numout,*) ' sn_cfctl%ptimincr = ', sn_cfctl%ptimincr |
---|
[3324] | 411 | WRITE(numout,*) ' level of print nn_print = ', nn_print |
---|
| 412 | WRITE(numout,*) ' Start i indice for SUM control nn_ictls = ', nn_ictls |
---|
| 413 | WRITE(numout,*) ' End i indice for SUM control nn_ictle = ', nn_ictle |
---|
| 414 | WRITE(numout,*) ' Start j indice for SUM control nn_jctls = ', nn_jctls |
---|
| 415 | WRITE(numout,*) ' End j indice for SUM control nn_jctle = ', nn_jctle |
---|
| 416 | WRITE(numout,*) ' number of proc. following i nn_isplt = ', nn_isplt |
---|
| 417 | WRITE(numout,*) ' number of proc. following j nn_jsplt = ', nn_jsplt |
---|
[9019] | 418 | WRITE(numout,*) ' timing by routine ln_timing = ', ln_timing |
---|
| 419 | WRITE(numout,*) ' CFL diagnostics ln_diacfl = ', ln_diacfl |
---|
[3324] | 420 | ENDIF |
---|
| 421 | ! |
---|
| 422 | nprint = nn_print ! convert DOCTOR namelist names into OLD names |
---|
| 423 | nictls = nn_ictls |
---|
| 424 | nictle = nn_ictle |
---|
| 425 | njctls = nn_jctls |
---|
| 426 | njctle = nn_jctle |
---|
| 427 | isplt = nn_isplt |
---|
| 428 | jsplt = nn_jsplt |
---|
[4147] | 429 | |
---|
| 430 | IF(lwp) THEN ! control print |
---|
| 431 | WRITE(numout,*) |
---|
| 432 | WRITE(numout,*) ' Namelist namcfg' |
---|
[9213] | 433 | WRITE(numout,*) ' read domain configuration file ln_read_cfg = ', ln_read_cfg |
---|
[7646] | 434 | WRITE(numout,*) ' filename to be read cn_domcfg = ', TRIM(cn_domcfg) |
---|
[9213] | 435 | WRITE(numout,*) ' keep closed seas in the domain (if exist) ln_closea = ', ln_closea |
---|
| 436 | WRITE(numout,*) ' create a configuration definition file ln_write_cfg = ', ln_write_cfg |
---|
[7646] | 437 | WRITE(numout,*) ' filename to be written cn_domcfg_out = ', TRIM(cn_domcfg_out) |
---|
| 438 | WRITE(numout,*) ' use file attribute if exists as i/p j-start ln_use_jattr = ', ln_use_jattr |
---|
[4147] | 439 | ENDIF |
---|
[9213] | 440 | IF( .NOT.ln_read_cfg ) ln_closea = .false. ! dealing possible only with a domcfg file |
---|
| 441 | ! |
---|
[3324] | 442 | ! ! Parameter control |
---|
| 443 | ! |
---|
[12377] | 444 | IF( sn_cfctl%l_prtctl .OR. sn_cfctl%l_prttrc ) THEN ! sub-domain area indices for the control prints |
---|
[3324] | 445 | IF( lk_mpp .AND. jpnij > 1 ) THEN |
---|
| 446 | isplt = jpni ; jsplt = jpnj ; ijsplt = jpni*jpnj ! the domain is forced to the real split domain |
---|
| 447 | ELSE |
---|
| 448 | IF( isplt == 1 .AND. jsplt == 1 ) THEN |
---|
| 449 | CALL ctl_warn( ' - isplt & jsplt are equal to 1', & |
---|
| 450 | & ' - the print control will be done over the whole domain' ) |
---|
| 451 | ENDIF |
---|
| 452 | ijsplt = isplt * jsplt ! total number of processors ijsplt |
---|
| 453 | ENDIF |
---|
| 454 | IF(lwp) WRITE(numout,*)' - The total number of processors over which the' |
---|
| 455 | IF(lwp) WRITE(numout,*)' print control will be done is ijsplt : ', ijsplt |
---|
| 456 | ! |
---|
| 457 | ! ! indices used for the SUM control |
---|
| 458 | IF( nictls+nictle+njctls+njctle == 0 ) THEN ! print control done over the default area |
---|
[7646] | 459 | lsp_area = .FALSE. |
---|
[3324] | 460 | ELSE ! print control done over a specific area |
---|
| 461 | lsp_area = .TRUE. |
---|
| 462 | IF( nictls < 1 .OR. nictls > jpiglo ) THEN |
---|
| 463 | CALL ctl_warn( ' - nictls must be 1<=nictls>=jpiglo, it is forced to 1' ) |
---|
| 464 | nictls = 1 |
---|
| 465 | ENDIF |
---|
| 466 | IF( nictle < 1 .OR. nictle > jpiglo ) THEN |
---|
| 467 | CALL ctl_warn( ' - nictle must be 1<=nictle>=jpiglo, it is forced to jpiglo' ) |
---|
| 468 | nictle = jpiglo |
---|
| 469 | ENDIF |
---|
| 470 | IF( njctls < 1 .OR. njctls > jpjglo ) THEN |
---|
| 471 | CALL ctl_warn( ' - njctls must be 1<=njctls>=jpjglo, it is forced to 1' ) |
---|
| 472 | njctls = 1 |
---|
| 473 | ENDIF |
---|
| 474 | IF( njctle < 1 .OR. njctle > jpjglo ) THEN |
---|
| 475 | CALL ctl_warn( ' - njctle must be 1<=njctle>=jpjglo, it is forced to jpjglo' ) |
---|
| 476 | njctle = jpjglo |
---|
| 477 | ENDIF |
---|
| 478 | ENDIF |
---|
| 479 | ENDIF |
---|
| 480 | ! |
---|
[9213] | 481 | IF( 1._wp /= SIGN(1._wp,-0._wp) ) CALL ctl_stop( 'nemo_ctl: The intrinsec SIGN function follows f2003 standard.', & |
---|
[11229] | 482 | & 'Compile with key_nosignedzero enabled:', & |
---|
| 483 | & '--> add -Dkey_nosignedzero to the definition of %CPP in your arch file' ) |
---|
[5407] | 484 | ! |
---|
[9213] | 485 | #if defined key_agrif |
---|
| 486 | IF( ln_timing ) CALL ctl_stop( 'AGRIF not implemented with ln_timing = true') |
---|
| 487 | #endif |
---|
| 488 | ! |
---|
[3324] | 489 | END SUBROUTINE nemo_ctl |
---|
| 490 | |
---|
| 491 | |
---|
| 492 | SUBROUTINE nemo_closefile |
---|
| 493 | !!---------------------------------------------------------------------- |
---|
| 494 | !! *** ROUTINE nemo_closefile *** |
---|
| 495 | !! |
---|
| 496 | !! ** Purpose : Close the files |
---|
| 497 | !!---------------------------------------------------------------------- |
---|
| 498 | ! |
---|
| 499 | IF( lk_mpp ) CALL mppsync |
---|
| 500 | ! |
---|
| 501 | CALL iom_close ! close all input/output files managed by iom_* |
---|
| 502 | ! |
---|
[9213] | 503 | IF( numstp /= -1 ) CLOSE( numstp ) ! time-step file |
---|
[9267] | 504 | IF( numrun /= -1 ) CLOSE( numrun ) ! run statistics file |
---|
[4624] | 505 | IF( lwm.AND.numond /= -1 ) CLOSE( numond ) ! oce output namelist |
---|
| 506 | IF( lwm.AND.numoni /= -1 ) CLOSE( numoni ) ! ice output namelist |
---|
[9213] | 507 | IF( numevo_ice /= -1 ) CLOSE( numevo_ice ) ! ice variables (temp. evolution) |
---|
| 508 | IF( numout /= 6 ) CLOSE( numout ) ! standard model output file |
---|
[3324] | 509 | ! |
---|
| 510 | numout = 6 ! redefine numout in case it is used after this point... |
---|
| 511 | ! |
---|
| 512 | END SUBROUTINE nemo_closefile |
---|
| 513 | |
---|
| 514 | |
---|
| 515 | SUBROUTINE nemo_alloc |
---|
| 516 | !!---------------------------------------------------------------------- |
---|
| 517 | !! *** ROUTINE nemo_alloc *** |
---|
| 518 | !! |
---|
| 519 | !! ** Purpose : Allocate all the dynamic arrays of the OPA modules |
---|
| 520 | !! |
---|
| 521 | !! ** Method : |
---|
| 522 | !!---------------------------------------------------------------------- |
---|
[9213] | 523 | USE diawri , ONLY : dia_wri_alloc |
---|
| 524 | USE dom_oce , ONLY : dom_oce_alloc |
---|
| 525 | USE bdy_oce , ONLY : ln_bdy, bdy_oce_alloc |
---|
[9019] | 526 | USE oce ! mandatory for sea-ice because needed for bdy arrays |
---|
[3324] | 527 | ! |
---|
[7646] | 528 | INTEGER :: ierr |
---|
[3324] | 529 | !!---------------------------------------------------------------------- |
---|
| 530 | ! |
---|
[9213] | 531 | ierr = dia_wri_alloc() |
---|
| 532 | ierr = ierr + dom_oce_alloc() ! ocean domain |
---|
[9570] | 533 | ierr = ierr + oce_alloc () ! (tsn...) needed for agrif and/or SI3 and bdy |
---|
[9213] | 534 | ierr = ierr + bdy_oce_alloc() ! bdy masks (incl. initialization) |
---|
[3324] | 535 | ! |
---|
[10425] | 536 | CALL mpp_sum( 'nemogcm', ierr ) |
---|
[9213] | 537 | IF( ierr /= 0 ) CALL ctl_stop( 'STOP', 'nemo_alloc: unable to allocate standard ocean arrays' ) |
---|
[3324] | 538 | ! |
---|
| 539 | END SUBROUTINE nemo_alloc |
---|
| 540 | |
---|
[12939] | 541 | SUBROUTINE nemo_set_cfctl(sn_cfctl, setto ) |
---|
[10570] | 542 | !!---------------------------------------------------------------------- |
---|
| 543 | !! *** ROUTINE nemo_set_cfctl *** |
---|
| 544 | !! |
---|
| 545 | !! ** Purpose : Set elements of the output control structure to setto. |
---|
| 546 | !! |
---|
| 547 | !! ** Method : Note this routine can be used to switch on/off some |
---|
[12939] | 548 | !! types of output for selected areas. |
---|
[10570] | 549 | !!---------------------------------------------------------------------- |
---|
[12939] | 550 | TYPE(sn_ctl), INTENT(inout) :: sn_cfctl |
---|
| 551 | LOGICAL , INTENT(in ) :: setto |
---|
[10570] | 552 | !!---------------------------------------------------------------------- |
---|
[12939] | 553 | sn_cfctl%l_runstat = setto |
---|
| 554 | sn_cfctl%l_trcstat = setto |
---|
[10570] | 555 | sn_cfctl%l_oceout = setto |
---|
| 556 | sn_cfctl%l_layout = setto |
---|
[12377] | 557 | sn_cfctl%l_prtctl = setto |
---|
| 558 | sn_cfctl%l_prttrc = setto |
---|
| 559 | sn_cfctl%l_oasout = setto |
---|
[10570] | 560 | END SUBROUTINE nemo_set_cfctl |
---|
| 561 | |
---|
[3324] | 562 | !!====================================================================== |
---|
| 563 | END MODULE nemogcm |
---|
[9213] | 564 | |
---|