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