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