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