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