1 | MODULE nemogcm |
---|
2 | !!====================================================================== |
---|
3 | !! *** MODULE nemogcm *** |
---|
4 | !! Off-line Ocean : passive tracer evolution, dynamics read in files |
---|
5 | !!====================================================================== |
---|
6 | !! History : 3.3 ! 2010-05 (C. Ethe) Full reorganization of the off-line: phasing with the on-line |
---|
7 | !! 4.0 ! 2011-01 (C. Ethe, A. R. Porter, STFC Daresbury) dynamical allocation |
---|
8 | !!---------------------------------------------------------------------- |
---|
9 | |
---|
10 | !!---------------------------------------------------------------------- |
---|
11 | !! nemo_gcm : off-line: solve ocean tracer only |
---|
12 | !! nemo_init : initialization of the nemo model |
---|
13 | !! nemo_ctl : initialisation of algorithm flag |
---|
14 | !! nemo_closefile : close remaining files |
---|
15 | !!---------------------------------------------------------------------- |
---|
16 | USE dom_oce ! ocean space domain variables |
---|
17 | USE oce ! dynamics and tracers variables |
---|
18 | USE c1d ! 1D configuration |
---|
19 | USE domcfg ! domain configuration (dom_cfg routine) |
---|
20 | USE domain ! domain initialization from coordinate & bathymetry (dom_init routine) |
---|
21 | USE domrea ! domain initialization from mesh_mask (dom_init routine) |
---|
22 | USE eosbn2 ! equation of state (eos bn2 routine) |
---|
23 | ! ! ocean physics |
---|
24 | USE ldftra ! lateral diffusivity setting (ldf_tra_init routine) |
---|
25 | USE ldfslp ! slopes of neutral surfaces (ldf_slp_init routine) |
---|
26 | USE traqsr ! solar radiation penetration (tra_qsr_init routine) |
---|
27 | USE trabbl ! bottom boundary layer (tra_bbl_init routine) |
---|
28 | USE zdfini ! vertical physics: initialization |
---|
29 | USE sbcmod ! surface boundary condition (sbc_init routine) |
---|
30 | USE phycst ! physical constant (par_cst routine) |
---|
31 | USE dtadyn ! Lecture and Interpolation of the dynamical fields |
---|
32 | USE trcini ! Initilization of the passive tracers |
---|
33 | USE daymod ! calendar (day routine) |
---|
34 | USE trcstp ! passive tracer time-stepping (trc_stp routine) |
---|
35 | USE dtadyn ! Lecture and interpolation of the dynamical fields |
---|
36 | ! ! I/O & MPP |
---|
37 | USE iom ! I/O library |
---|
38 | USE in_out_manager ! I/O manager |
---|
39 | USE mppini ! shared/distributed memory setting (mpp_init routine) |
---|
40 | USE lib_mpp ! distributed memory computing |
---|
41 | #if defined key_iomput |
---|
42 | USE xios |
---|
43 | #endif |
---|
44 | USE prtctl ! Print control (prt_ctl_init routine) |
---|
45 | USE timing ! Timing |
---|
46 | USE lib_fortran ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined) |
---|
47 | USE lbcnfd, ONLY: isendto, nsndto, nfsloop, nfeloop ! Setup of north fold exchanges |
---|
48 | |
---|
49 | USE trc |
---|
50 | USE trcnam |
---|
51 | USE trcrst |
---|
52 | USE diaptr ! Need to initialise this as some variables are used in if statements later |
---|
53 | |
---|
54 | IMPLICIT NONE |
---|
55 | PRIVATE |
---|
56 | |
---|
57 | PUBLIC nemo_gcm ! called by nemo.F90 |
---|
58 | |
---|
59 | CHARACTER (len=64) :: cform_aaa="( /, 'AAAAAAAA', / ) " ! flag for output listing |
---|
60 | |
---|
61 | !!---------------------------------------------------------------------- |
---|
62 | !! NEMO/OFF 3.3 , NEMO Consortium (2010) |
---|
63 | !! $Id$ |
---|
64 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
65 | !!---------------------------------------------------------------------- |
---|
66 | CONTAINS |
---|
67 | |
---|
68 | SUBROUTINE nemo_gcm |
---|
69 | !!---------------------------------------------------------------------- |
---|
70 | !! *** ROUTINE nemo_gcm *** |
---|
71 | !! |
---|
72 | !! ** Purpose : nemo solves the primitive equations on an orthogonal |
---|
73 | !! curvilinear mesh on the sphere. |
---|
74 | !! |
---|
75 | !! ** Method : - model general initialization |
---|
76 | !! - launch the time-stepping (dta_dyn and trc_stp) |
---|
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 | !!---------------------------------------------------------------------- |
---|
82 | INTEGER :: istp, indic ! time step index |
---|
83 | !!---------------------------------------------------------------------- |
---|
84 | |
---|
85 | CALL nemo_init ! Initializations |
---|
86 | |
---|
87 | ! check that all process are still there... If some process have an error, |
---|
88 | ! they will never enter in step and other processes will wait until the end of the cpu time! |
---|
89 | IF( lk_mpp ) CALL mpp_max( nstop ) |
---|
90 | |
---|
91 | ! !-----------------------! |
---|
92 | ! !== time stepping ==! |
---|
93 | ! !-----------------------! |
---|
94 | istp = nit000 |
---|
95 | ! |
---|
96 | CALL iom_init( cxios_context ) ! iom_put initialization (must be done after nemo_init for AGRIF+XIOS+OASIS) |
---|
97 | ! |
---|
98 | DO WHILE ( istp <= nitend .AND. nstop == 0 ) ! time stepping |
---|
99 | ! |
---|
100 | IF( istp /= nit000 ) CALL day ( istp ) ! Calendar (day was already called at nit000 in day_init) |
---|
101 | CALL iom_setkt( istp - nit000 + 1, "nemo" ) ! say to iom that we are at time step kstp |
---|
102 | CALL dta_dyn ( istp ) ! Interpolation of the dynamical fields |
---|
103 | CALL trc_stp ( istp ) ! time-stepping |
---|
104 | CALL stp_ctl ( istp, indic ) ! Time loop: control and print |
---|
105 | istp = istp + 1 |
---|
106 | IF( lk_mpp ) CALL mpp_max( nstop ) |
---|
107 | END DO |
---|
108 | #if defined key_iomput |
---|
109 | CALL iom_context_finalize( cxios_context ) ! needed for XIOS+AGRIF |
---|
110 | #endif |
---|
111 | |
---|
112 | ! !------------------------! |
---|
113 | ! !== finalize the run ==! |
---|
114 | ! !------------------------! |
---|
115 | IF(lwp) WRITE(numout,cform_aaa) ! Flag AAAAAAA |
---|
116 | |
---|
117 | IF( nstop /= 0 .AND. lwp ) THEN ! error print |
---|
118 | WRITE(numout,cform_err) |
---|
119 | WRITE(numout,*) nstop, ' error have been found' |
---|
120 | ENDIF |
---|
121 | ! |
---|
122 | IF( nn_timing == 1 ) CALL timing_finalize |
---|
123 | ! |
---|
124 | CALL nemo_closefile |
---|
125 | ! |
---|
126 | # if defined key_iomput |
---|
127 | CALL xios_finalize ! end mpp communications |
---|
128 | # else |
---|
129 | IF( lk_mpp ) CALL mppstop ! end mpp communications |
---|
130 | # endif |
---|
131 | ! |
---|
132 | END SUBROUTINE nemo_gcm |
---|
133 | |
---|
134 | |
---|
135 | SUBROUTINE nemo_init |
---|
136 | !!---------------------------------------------------------------------- |
---|
137 | !! *** ROUTINE nemo_init *** |
---|
138 | !! |
---|
139 | !! ** Purpose : initialization of the nemo model in off-line mode |
---|
140 | !!---------------------------------------------------------------------- |
---|
141 | INTEGER :: ji ! dummy loop indices |
---|
142 | INTEGER :: ilocal_comm ! local integer |
---|
143 | INTEGER :: ios |
---|
144 | LOGICAL :: llexist |
---|
145 | CHARACTER(len=80), DIMENSION(16) :: cltxt |
---|
146 | !! |
---|
147 | NAMELIST/namctl/ ln_ctl , nn_print, nn_ictls, nn_ictle, & |
---|
148 | & nn_isplt, nn_jsplt, nn_jctls, nn_jctle, & |
---|
149 | & nn_bench, nn_timing |
---|
150 | NAMELIST/namcfg/ cp_cfg, cp_cfz, jp_cfg, jpidta, jpjdta, jpkdta, jpiglo, jpjglo, & |
---|
151 | & jpizoom, jpjzoom, jperio, ln_use_jattr |
---|
152 | !!---------------------------------------------------------------------- |
---|
153 | cltxt = '' |
---|
154 | cxios_context = 'nemo' |
---|
155 | ! |
---|
156 | ! ! Open reference namelist and configuration namelist files |
---|
157 | CALL ctl_opn( numnam_ref, 'namelist_ref', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. ) |
---|
158 | CALL ctl_opn( numnam_cfg, 'namelist_cfg', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. ) |
---|
159 | ! |
---|
160 | REWIND( numnam_ref ) ! Namelist namctl in reference namelist : Control prints & Benchmark |
---|
161 | READ ( numnam_ref, namctl, IOSTAT = ios, ERR = 901 ) |
---|
162 | 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namctl in reference namelist', .TRUE. ) |
---|
163 | |
---|
164 | REWIND( numnam_cfg ) ! Namelist namctl in confguration namelist : Control prints & Benchmark |
---|
165 | READ ( numnam_cfg, namctl, IOSTAT = ios, ERR = 902 ) |
---|
166 | 902 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namctl in configuration namelist', .TRUE. ) |
---|
167 | |
---|
168 | ! |
---|
169 | REWIND( numnam_ref ) ! Namelist namcfg in reference namelist : Control prints & Benchmark |
---|
170 | READ ( numnam_ref, namcfg, IOSTAT = ios, ERR = 903 ) |
---|
171 | 903 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namcfg in reference namelist', .TRUE. ) |
---|
172 | |
---|
173 | REWIND( numnam_cfg ) ! Namelist namcfg in confguration namelist : Control prints & Benchmark |
---|
174 | READ ( numnam_cfg, namcfg, IOSTAT = ios, ERR = 904 ) |
---|
175 | 904 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namcfg in configuration namelist', .TRUE. ) |
---|
176 | |
---|
177 | ! |
---|
178 | ! !--------------------------------------------! |
---|
179 | ! ! set communicator & select the local node ! |
---|
180 | ! ! NB: mynode also opens output.namelist.dyn ! |
---|
181 | ! ! on unit number numond on first proc ! |
---|
182 | ! !--------------------------------------------! |
---|
183 | #if defined key_iomput |
---|
184 | CALL xios_initialize( "for_xios_mpi_id",return_comm=ilocal_comm ) |
---|
185 | narea = mynode( cltxt, 'output.namelist.dyn', numnam_ref, numnam_cfg, numond , nstop, ilocal_comm ) ! Nodes selection |
---|
186 | #else |
---|
187 | ilocal_comm = 0 |
---|
188 | narea = mynode( cltxt, 'output.namelist.dyn', numnam_ref, numnam_cfg, numond , nstop ) ! Nodes selection (control print return in cltxt) |
---|
189 | #endif |
---|
190 | |
---|
191 | narea = narea + 1 ! mynode return the rank of proc (0 --> jpnij -1 ) |
---|
192 | |
---|
193 | lwm = (narea == 1) ! control of output namelists |
---|
194 | lwp = (narea == 1) .OR. ln_ctl ! control of all listing output print |
---|
195 | |
---|
196 | IF(lwm) THEN |
---|
197 | ! write merged namelists from earlier to output namelist now that the |
---|
198 | ! file has been opened in call to mynode. nammpp has already been |
---|
199 | ! written in mynode (if lk_mpp_mpi) |
---|
200 | WRITE( numond, namctl ) |
---|
201 | WRITE( numond, namcfg ) |
---|
202 | ENDIF |
---|
203 | |
---|
204 | ! If dimensions of processor grid weren't specified in the namelist file |
---|
205 | ! then we calculate them here now that we have our communicator size |
---|
206 | IF( (jpni < 1) .OR. (jpnj < 1) )THEN |
---|
207 | #if defined key_mpp_mpi |
---|
208 | CALL nemo_partition(mppsize) |
---|
209 | #else |
---|
210 | jpni = 1 |
---|
211 | jpnj = 1 |
---|
212 | jpnij = jpni*jpnj |
---|
213 | #endif |
---|
214 | END IF |
---|
215 | |
---|
216 | ! Calculate domain dimensions given calculated jpni and jpnj |
---|
217 | ! This used to be done in par_oce.F90 when they were parameters rather |
---|
218 | ! than variables |
---|
219 | jpi = ( jpiglo-2*jpreci + (jpni-1) ) / jpni + 2*jpreci ! first dim. |
---|
220 | jpj = ( jpjglo-2*jprecj + (jpnj-1) ) / jpnj + 2*jprecj ! second dim. |
---|
221 | jpk = jpkdta ! third dim |
---|
222 | jpim1 = jpi-1 ! inner domain indices |
---|
223 | jpjm1 = jpj-1 ! " " |
---|
224 | jpkm1 = jpk-1 ! " " |
---|
225 | jpij = jpi*jpj ! jpi x j |
---|
226 | |
---|
227 | |
---|
228 | IF(lwp) THEN ! open listing units |
---|
229 | ! |
---|
230 | CALL ctl_opn( numout, 'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea ) |
---|
231 | ! |
---|
232 | WRITE(numout,*) |
---|
233 | WRITE(numout,*) ' CNRS - NERC - Met OFFICE - MERCATOR-ocean - INGV - CMCC' |
---|
234 | WRITE(numout,*) ' NEMO team' |
---|
235 | WRITE(numout,*) ' Ocean General Circulation Model' |
---|
236 | WRITE(numout,*) ' version 3.6 (2015) ' |
---|
237 | WRITE(numout,*) |
---|
238 | WRITE(numout,*) |
---|
239 | DO ji = 1, SIZE(cltxt) |
---|
240 | IF( TRIM(cltxt(ji)) /= '' ) WRITE(numout,*) cltxt(ji) ! control print of mynode |
---|
241 | END DO |
---|
242 | WRITE(numout,cform_aaa) ! Flag AAAAAAA |
---|
243 | ! |
---|
244 | ENDIF |
---|
245 | |
---|
246 | ! Now we know the dimensions of the grid and numout has been set we can |
---|
247 | ! allocate arrays |
---|
248 | CALL nemo_alloc() |
---|
249 | |
---|
250 | ! !--------------------------------! |
---|
251 | ! ! Model general initialization ! |
---|
252 | ! !--------------------------------! |
---|
253 | |
---|
254 | CALL nemo_ctl ! Control prints & Benchmark |
---|
255 | |
---|
256 | ! ! Domain decomposition |
---|
257 | IF( jpni*jpnj == jpnij ) THEN ; CALL mpp_init ! standard cutting out |
---|
258 | ELSE ; CALL mpp_init2 ! eliminate land processors |
---|
259 | ENDIF |
---|
260 | ! |
---|
261 | IF( nn_timing == 1 ) CALL timing_init |
---|
262 | ! |
---|
263 | |
---|
264 | ! ! General initialization |
---|
265 | IF( nn_timing == 1 ) CALL timing_start( 'nemo_init') |
---|
266 | ! |
---|
267 | CALL phy_cst ! Physical constants |
---|
268 | CALL eos_init ! Equation of state |
---|
269 | IF( lk_c1d ) CALL c1d_init ! 1D column configuration |
---|
270 | CALL dom_cfg ! Domain configuration |
---|
271 | ! |
---|
272 | INQUIRE( FILE='coordinates.nc', EXIST = llexist ) ! Check if coordinate file exist |
---|
273 | ! |
---|
274 | IF( llexist ) THEN ; CALL dom_init ! compute the grid from coordinates and bathymetry |
---|
275 | ELSE ; CALL dom_rea ! read grid from the meskmask |
---|
276 | ENDIF |
---|
277 | CALL istate_init ! ocean initial state (Dynamics and tracers) |
---|
278 | |
---|
279 | IF( ln_nnogather ) CALL nemo_northcomms ! Initialise the northfold neighbour lists (must be done after the masks are defined) |
---|
280 | |
---|
281 | IF( ln_ctl ) CALL prt_ctl_init ! Print control |
---|
282 | |
---|
283 | CALL sbc_init ! Forcings : surface module |
---|
284 | |
---|
285 | #if ! defined key_degrad |
---|
286 | CALL ldf_tra_init ! Lateral ocean tracer physics |
---|
287 | #endif |
---|
288 | IF( lk_ldfslp ) CALL ldf_slp_init ! slope of lateral mixing |
---|
289 | |
---|
290 | CALL tra_qsr_init ! penetrative solar radiation qsr |
---|
291 | IF( lk_trabbl ) CALL tra_bbl_init ! advective (and/or diffusive) bottom boundary layer scheme |
---|
292 | |
---|
293 | CALL trc_nam_run ! Needed to get restart parameters for passive tracers |
---|
294 | CALL trc_rst_cal( nit000, 'READ' ) ! calendar |
---|
295 | CALL dta_dyn_init ! Initialization for the dynamics |
---|
296 | |
---|
297 | CALL trc_init ! Passive tracers initialization |
---|
298 | CALL dia_ptr_init ! Initialise diaptr as some variables are used |
---|
299 | ! ! in various advection and diffusion routines |
---|
300 | IF(lwp) WRITE(numout,cform_aaa) ! Flag AAAAAAA |
---|
301 | ! |
---|
302 | IF( nn_timing == 1 ) CALL timing_stop( 'nemo_init') |
---|
303 | ! |
---|
304 | END SUBROUTINE nemo_init |
---|
305 | |
---|
306 | |
---|
307 | SUBROUTINE nemo_ctl |
---|
308 | !!---------------------------------------------------------------------- |
---|
309 | !! *** ROUTINE nemo_ctl *** |
---|
310 | !! |
---|
311 | !! ** Purpose : control print setting |
---|
312 | !! |
---|
313 | !! ** Method : - print namctl information and check some consistencies |
---|
314 | !!---------------------------------------------------------------------- |
---|
315 | ! |
---|
316 | IF(lwp) THEN ! Parameter print |
---|
317 | WRITE(numout,*) |
---|
318 | WRITE(numout,*) 'nemo_flg: Control prints & Benchmark' |
---|
319 | WRITE(numout,*) '~~~~~~~ ' |
---|
320 | WRITE(numout,*) ' Namelist namctl' |
---|
321 | WRITE(numout,*) ' run control (for debugging) ln_ctl = ', ln_ctl |
---|
322 | WRITE(numout,*) ' level of print nn_print = ', nn_print |
---|
323 | WRITE(numout,*) ' Start i indice for SUM control nn_ictls = ', nn_ictls |
---|
324 | WRITE(numout,*) ' End i indice for SUM control nn_ictle = ', nn_ictle |
---|
325 | WRITE(numout,*) ' Start j indice for SUM control nn_jctls = ', nn_jctls |
---|
326 | WRITE(numout,*) ' End j indice for SUM control nn_jctle = ', nn_jctle |
---|
327 | WRITE(numout,*) ' number of proc. following i nn_isplt = ', nn_isplt |
---|
328 | WRITE(numout,*) ' number of proc. following j nn_jsplt = ', nn_jsplt |
---|
329 | WRITE(numout,*) ' benchmark parameter (0/1) nn_bench = ', nn_bench |
---|
330 | ENDIF |
---|
331 | ! |
---|
332 | nprint = nn_print ! convert DOCTOR namelist names into OLD names |
---|
333 | nictls = nn_ictls |
---|
334 | nictle = nn_ictle |
---|
335 | njctls = nn_jctls |
---|
336 | njctle = nn_jctle |
---|
337 | isplt = nn_isplt |
---|
338 | jsplt = nn_jsplt |
---|
339 | nbench = nn_bench |
---|
340 | IF(lwp) THEN ! control print |
---|
341 | WRITE(numout,*) |
---|
342 | WRITE(numout,*) 'namcfg : configuration initialization through namelist read' |
---|
343 | WRITE(numout,*) '~~~~~~~ ' |
---|
344 | WRITE(numout,*) ' Namelist namcfg' |
---|
345 | WRITE(numout,*) ' configuration name cp_cfg = ', TRIM(cp_cfg) |
---|
346 | WRITE(numout,*) ' configuration resolution jp_cfg = ', jp_cfg |
---|
347 | WRITE(numout,*) ' 1st lateral dimension ( >= jpi ) jpidta = ', jpidta |
---|
348 | WRITE(numout,*) ' 2nd " " ( >= jpj ) jpjdta = ', jpjdta |
---|
349 | WRITE(numout,*) ' 3nd " " jpkdta = ', jpkdta |
---|
350 | WRITE(numout,*) ' 1st dimension of global domain in i jpiglo = ', jpiglo |
---|
351 | WRITE(numout,*) ' 2nd - - in j jpjglo = ', jpjglo |
---|
352 | WRITE(numout,*) ' left bottom i index of the zoom (in data domain) jpizoom = ', jpizoom |
---|
353 | WRITE(numout,*) ' left bottom j index of the zoom (in data domain) jpizoom = ', jpjzoom |
---|
354 | WRITE(numout,*) ' lateral cond. type (between 0 and 6) jperio = ', jperio |
---|
355 | WRITE(numout,*) ' use file attribute if exists as i/p j-start ln_use_jattr = ', ln_use_jattr |
---|
356 | ENDIF |
---|
357 | ! ! Parameter control |
---|
358 | ! |
---|
359 | IF( ln_ctl ) THEN ! sub-domain area indices for the control prints |
---|
360 | IF( lk_mpp ) THEN |
---|
361 | isplt = jpni ; jsplt = jpnj ; ijsplt = jpni*jpnj ! the domain is forced to the real splitted domain |
---|
362 | ELSE |
---|
363 | IF( isplt == 1 .AND. jsplt == 1 ) THEN |
---|
364 | CALL ctl_warn( ' - isplt & jsplt are equal to 1', & |
---|
365 | & ' - the print control will be done over the whole domain' ) |
---|
366 | ENDIF |
---|
367 | ijsplt = isplt * jsplt ! total number of processors ijsplt |
---|
368 | ENDIF |
---|
369 | IF(lwp) WRITE(numout,*)' - The total number of processors over which the' |
---|
370 | IF(lwp) WRITE(numout,*)' print control will be done is ijsplt : ', ijsplt |
---|
371 | ! |
---|
372 | ! ! indices used for the SUM control |
---|
373 | IF( nictls+nictle+njctls+njctle == 0 ) THEN ! print control done over the default area |
---|
374 | lsp_area = .FALSE. |
---|
375 | ELSE ! print control done over a specific area |
---|
376 | lsp_area = .TRUE. |
---|
377 | IF( nictls < 1 .OR. nictls > jpiglo ) THEN |
---|
378 | CALL ctl_warn( ' - nictls must be 1<=nictls>=jpiglo, it is forced to 1' ) |
---|
379 | nictls = 1 |
---|
380 | ENDIF |
---|
381 | IF( nictle < 1 .OR. nictle > jpiglo ) THEN |
---|
382 | CALL ctl_warn( ' - nictle must be 1<=nictle>=jpiglo, it is forced to jpiglo' ) |
---|
383 | nictle = jpiglo |
---|
384 | ENDIF |
---|
385 | IF( njctls < 1 .OR. njctls > jpjglo ) THEN |
---|
386 | CALL ctl_warn( ' - njctls must be 1<=njctls>=jpjglo, it is forced to 1' ) |
---|
387 | njctls = 1 |
---|
388 | ENDIF |
---|
389 | IF( njctle < 1 .OR. njctle > jpjglo ) THEN |
---|
390 | CALL ctl_warn( ' - njctle must be 1<=njctle>=jpjglo, it is forced to jpjglo' ) |
---|
391 | njctle = jpjglo |
---|
392 | ENDIF |
---|
393 | ENDIF |
---|
394 | ENDIF |
---|
395 | ! |
---|
396 | IF( nbench == 1 ) THEN ! Benchmark |
---|
397 | SELECT CASE ( cp_cfg ) |
---|
398 | CASE ( 'gyre' ) ; CALL ctl_warn( ' The Benchmark is activated ' ) |
---|
399 | CASE DEFAULT ; CALL ctl_stop( ' The Benchmark is based on the GYRE configuration:', & |
---|
400 | & ' cp_cfg="gyre" in namelsit &namcfg or set nbench = 0' ) |
---|
401 | END SELECT |
---|
402 | ENDIF |
---|
403 | ! |
---|
404 | IF( lk_c1d .AND. .NOT.lk_iomput ) CALL ctl_stop( 'nemo_ctl: The 1D configuration must be used ', & |
---|
405 | & 'with the IOM Input/Output manager. ' , & |
---|
406 | & 'Compile with key_iomput enabled' ) |
---|
407 | ! |
---|
408 | IF( 1_wp /= SIGN(1._wp,-0._wp) ) CALL ctl_stop( 'nemo_ctl: The intrinsec SIGN function follows ', & |
---|
409 | & 'f2003 standard. ' , & |
---|
410 | & 'Compile with key_nosignedzero enabled' ) |
---|
411 | ! |
---|
412 | END SUBROUTINE nemo_ctl |
---|
413 | |
---|
414 | |
---|
415 | SUBROUTINE nemo_closefile |
---|
416 | !!---------------------------------------------------------------------- |
---|
417 | !! *** ROUTINE nemo_closefile *** |
---|
418 | !! |
---|
419 | !! ** Purpose : Close the files |
---|
420 | !!---------------------------------------------------------------------- |
---|
421 | ! |
---|
422 | IF ( lk_mpp ) CALL mppsync |
---|
423 | ! |
---|
424 | CALL iom_close ! close all input/output files managed by iom_* |
---|
425 | ! |
---|
426 | IF( numstp /= -1 ) CLOSE( numstp ) ! time-step file |
---|
427 | IF( numnam_ref /= -1 ) CLOSE( numnam_ref ) ! oce reference namelist |
---|
428 | IF( numnam_cfg /= -1 ) CLOSE( numnam_cfg ) ! oce configuration namelist |
---|
429 | IF( numout /= 6 ) CLOSE( numout ) ! standard model output file |
---|
430 | numout = 6 ! redefine numout in case it is used after this point... |
---|
431 | ! |
---|
432 | END SUBROUTINE nemo_closefile |
---|
433 | |
---|
434 | |
---|
435 | SUBROUTINE nemo_alloc |
---|
436 | !!---------------------------------------------------------------------- |
---|
437 | !! *** ROUTINE nemo_alloc *** |
---|
438 | !! |
---|
439 | !! ** Purpose : Allocate all the dynamic arrays of the OPA modules |
---|
440 | !! |
---|
441 | !! ** Method : |
---|
442 | !!---------------------------------------------------------------------- |
---|
443 | USE diawri, ONLY: dia_wri_alloc |
---|
444 | USE dom_oce, ONLY: dom_oce_alloc |
---|
445 | USE zdf_oce, ONLY: zdf_oce_alloc |
---|
446 | USE ldftra_oce, ONLY: ldftra_oce_alloc |
---|
447 | USE trc_oce, ONLY: trc_oce_alloc |
---|
448 | ! |
---|
449 | INTEGER :: ierr |
---|
450 | !!---------------------------------------------------------------------- |
---|
451 | ! |
---|
452 | ierr = oce_alloc () ! ocean |
---|
453 | ierr = ierr + dia_wri_alloc () |
---|
454 | ierr = ierr + dom_oce_alloc () ! ocean domain |
---|
455 | ierr = ierr + ldftra_oce_alloc() ! ocean lateral physics : tracers |
---|
456 | ierr = ierr + zdf_oce_alloc () ! ocean vertical physics |
---|
457 | ! |
---|
458 | ierr = ierr + trc_oce_alloc () ! shared TRC / TRA arrays |
---|
459 | ! |
---|
460 | IF( lk_mpp ) CALL mpp_sum( ierr ) |
---|
461 | IF( ierr /= 0 ) CALL ctl_stop( 'STOP', 'nemo_alloc: unable to allocate standard ocean arrays' ) |
---|
462 | ! |
---|
463 | END SUBROUTINE nemo_alloc |
---|
464 | |
---|
465 | |
---|
466 | SUBROUTINE nemo_partition( num_pes ) |
---|
467 | !!---------------------------------------------------------------------- |
---|
468 | !! *** ROUTINE nemo_partition *** |
---|
469 | !! |
---|
470 | !! ** Purpose : |
---|
471 | !! |
---|
472 | !! ** Method : |
---|
473 | !!---------------------------------------------------------------------- |
---|
474 | INTEGER, INTENT(in) :: num_pes ! The number of MPI processes we have |
---|
475 | ! |
---|
476 | INTEGER, PARAMETER :: nfactmax = 20 |
---|
477 | INTEGER :: nfact ! The no. of factors returned |
---|
478 | INTEGER :: ierr ! Error flag |
---|
479 | INTEGER :: ji |
---|
480 | INTEGER :: idiff, mindiff, imin ! For choosing pair of factors that are closest in value |
---|
481 | INTEGER, DIMENSION(nfactmax) :: ifact ! Array of factors |
---|
482 | !!---------------------------------------------------------------------- |
---|
483 | |
---|
484 | ierr = 0 |
---|
485 | |
---|
486 | CALL factorise( ifact, nfactmax, nfact, num_pes, ierr ) |
---|
487 | |
---|
488 | IF( nfact <= 1 ) THEN |
---|
489 | WRITE (numout, *) 'WARNING: factorisation of number of PEs failed' |
---|
490 | WRITE (numout, *) ' : using grid of ',num_pes,' x 1' |
---|
491 | jpnj = 1 |
---|
492 | jpni = num_pes |
---|
493 | ELSE |
---|
494 | ! Search through factors for the pair that are closest in value |
---|
495 | mindiff = 1000000 |
---|
496 | imin = 1 |
---|
497 | DO ji = 1, nfact-1, 2 |
---|
498 | idiff = ABS( ifact(ji) - ifact(ji+1) ) |
---|
499 | IF( idiff < mindiff ) THEN |
---|
500 | mindiff = idiff |
---|
501 | imin = ji |
---|
502 | ENDIF |
---|
503 | END DO |
---|
504 | jpnj = ifact(imin) |
---|
505 | jpni = ifact(imin + 1) |
---|
506 | ENDIF |
---|
507 | ! |
---|
508 | jpnij = jpni*jpnj |
---|
509 | ! |
---|
510 | END SUBROUTINE nemo_partition |
---|
511 | |
---|
512 | |
---|
513 | SUBROUTINE factorise( kfax, kmaxfax, knfax, kn, kerr ) |
---|
514 | !!---------------------------------------------------------------------- |
---|
515 | !! *** ROUTINE factorise *** |
---|
516 | !! |
---|
517 | !! ** Purpose : return the prime factors of n. |
---|
518 | !! knfax factors are returned in array kfax which is of |
---|
519 | !! maximum dimension kmaxfax. |
---|
520 | !! ** Method : |
---|
521 | !!---------------------------------------------------------------------- |
---|
522 | INTEGER , INTENT(in ) :: kn, kmaxfax |
---|
523 | INTEGER , INTENT( out) :: kerr, knfax |
---|
524 | INTEGER, DIMENSION(kmaxfax), INTENT( out) :: kfax |
---|
525 | ! |
---|
526 | INTEGER :: ifac, jl, inu |
---|
527 | INTEGER, PARAMETER :: ntest = 14 |
---|
528 | INTEGER :: ilfax(ntest) |
---|
529 | ! |
---|
530 | ! lfax contains the set of allowed factors. |
---|
531 | data (ilfax(jl),jl=1,ntest) / 16384, 8192, 4096, 2048, 1024, 512, 256, & |
---|
532 | & 128, 64, 32, 16, 8, 4, 2 / |
---|
533 | !!---------------------------------------------------------------------- |
---|
534 | |
---|
535 | ! Clear the error flag and initialise output vars |
---|
536 | kerr = 0 |
---|
537 | kfax = 1 |
---|
538 | knfax = 0 |
---|
539 | |
---|
540 | ! Find the factors of n. |
---|
541 | IF( kn == 1 ) GOTO 20 |
---|
542 | |
---|
543 | ! nu holds the unfactorised part of the number. |
---|
544 | ! knfax holds the number of factors found. |
---|
545 | ! l points to the allowed factor list. |
---|
546 | ! ifac holds the current factor. |
---|
547 | |
---|
548 | inu = kn |
---|
549 | knfax = 0 |
---|
550 | |
---|
551 | DO jl = ntest, 1, -1 |
---|
552 | ! |
---|
553 | ifac = ilfax(jl) |
---|
554 | IF( ifac > inu ) CYCLE |
---|
555 | |
---|
556 | ! Test whether the factor will divide. |
---|
557 | |
---|
558 | IF( MOD(inu,ifac) == 0 ) THEN |
---|
559 | ! |
---|
560 | knfax = knfax + 1 ! Add the factor to the list |
---|
561 | IF( knfax > kmaxfax ) THEN |
---|
562 | kerr = 6 |
---|
563 | write (*,*) 'FACTOR: insufficient space in factor array ', knfax |
---|
564 | return |
---|
565 | ENDIF |
---|
566 | kfax(knfax) = ifac |
---|
567 | ! Store the other factor that goes with this one |
---|
568 | knfax = knfax + 1 |
---|
569 | kfax(knfax) = inu / ifac |
---|
570 | !WRITE (*,*) 'ARPDBG, factors ',knfax-1,' & ',knfax,' are ', kfax(knfax-1),' and ',kfax(knfax) |
---|
571 | ENDIF |
---|
572 | ! |
---|
573 | END DO |
---|
574 | |
---|
575 | 20 CONTINUE ! Label 20 is the exit point from the factor search loop. |
---|
576 | ! |
---|
577 | END SUBROUTINE factorise |
---|
578 | |
---|
579 | #if defined key_mpp_mpi |
---|
580 | SUBROUTINE nemo_northcomms |
---|
581 | !!====================================================================== |
---|
582 | !! *** ROUTINE nemo_northcomms *** |
---|
583 | !! nemo_northcomms : Setup for north fold exchanges with explicit |
---|
584 | !! point-to-point messaging |
---|
585 | !!===================================================================== |
---|
586 | !!---------------------------------------------------------------------- |
---|
587 | !! |
---|
588 | !! ** Purpose : Initialization of the northern neighbours lists. |
---|
589 | !!---------------------------------------------------------------------- |
---|
590 | !! 1.0 ! 2011-10 (A. C. Coward, NOCS & J. Donners, PRACE) |
---|
591 | !! 2.0 ! 2013-06 Setup avoiding MPI communication (I. Epicoco, S. |
---|
592 | !Mocavero, CMCC) |
---|
593 | !!---------------------------------------------------------------------- |
---|
594 | |
---|
595 | INTEGER :: sxM, dxM, sxT, dxT, jn |
---|
596 | INTEGER :: njmppmax |
---|
597 | |
---|
598 | njmppmax = MAXVAL( njmppt ) |
---|
599 | |
---|
600 | !initializes the north-fold communication variables |
---|
601 | isendto(:) = 0 |
---|
602 | nsndto = 0 |
---|
603 | |
---|
604 | !if I am a process in the north |
---|
605 | IF ( njmpp == njmppmax ) THEN |
---|
606 | !sxM is the first point (in the global domain) needed to compute the |
---|
607 | !north-fold for the current process |
---|
608 | sxM = jpiglo - nimppt(narea) - nlcit(narea) + 1 |
---|
609 | !dxM is the last point (in the global domain) needed to compute the |
---|
610 | !north-fold for the current process |
---|
611 | dxM = jpiglo - nimppt(narea) + 2 |
---|
612 | |
---|
613 | !loop over the other north-fold processes to find the processes |
---|
614 | !managing the points belonging to the sxT-dxT range |
---|
615 | |
---|
616 | DO jn = 1, jpni |
---|
617 | !sxT is the first point (in the global domain) of the jn |
---|
618 | !process |
---|
619 | sxT = nfiimpp(jn, jpnj) |
---|
620 | !dxT is the last point (in the global domain) of the jn |
---|
621 | !process |
---|
622 | dxT = nfiimpp(jn, jpnj) + nfilcit(jn, jpnj) - 1 |
---|
623 | IF ((sxM .gt. sxT) .AND. (sxM .lt. dxT)) THEN |
---|
624 | nsndto = nsndto + 1 |
---|
625 | isendto(nsndto) = jn |
---|
626 | ELSEIF ((sxM .le. sxT) .AND. (dxM .ge. dxT)) THEN |
---|
627 | nsndto = nsndto + 1 |
---|
628 | isendto(nsndto) = jn |
---|
629 | ELSEIF ((dxM .lt. dxT) .AND. (sxT .lt. dxM)) THEN |
---|
630 | nsndto = nsndto + 1 |
---|
631 | isendto(nsndto) = jn |
---|
632 | END IF |
---|
633 | END DO |
---|
634 | nfsloop = 1 |
---|
635 | nfeloop = nlci |
---|
636 | DO jn = 2,jpni-1 |
---|
637 | IF(nfipproc(jn,jpnj) .eq. (narea - 1)) THEN |
---|
638 | IF (nfipproc(jn - 1 ,jpnj) .eq. -1) THEN |
---|
639 | nfsloop = nldi |
---|
640 | ENDIF |
---|
641 | IF (nfipproc(jn + 1,jpnj) .eq. -1) THEN |
---|
642 | nfeloop = nlei |
---|
643 | ENDIF |
---|
644 | ENDIF |
---|
645 | END DO |
---|
646 | |
---|
647 | ENDIF |
---|
648 | l_north_nogather = .TRUE. |
---|
649 | END SUBROUTINE nemo_northcomms |
---|
650 | #else |
---|
651 | SUBROUTINE nemo_northcomms ! Dummy routine |
---|
652 | WRITE(*,*) 'nemo_northcomms: You should not have seen this print! error?' |
---|
653 | END SUBROUTINE nemo_northcomms |
---|
654 | #endif |
---|
655 | |
---|
656 | SUBROUTINE istate_init |
---|
657 | !!---------------------------------------------------------------------- |
---|
658 | !! *** ROUTINE istate_init *** |
---|
659 | !! |
---|
660 | !! ** Purpose : Initialization to zero of the dynamics and tracers. |
---|
661 | !!---------------------------------------------------------------------- |
---|
662 | ! |
---|
663 | ! now fields ! after fields ! |
---|
664 | un (:,:,:) = 0._wp ; ua(:,:,:) = 0._wp ! |
---|
665 | vn (:,:,:) = 0._wp ; va(:,:,:) = 0._wp ! |
---|
666 | wn (:,:,:) = 0._wp ! ! |
---|
667 | hdivn(:,:,:) = 0._wp ! ! |
---|
668 | tsn (:,:,:,:) = 0._wp ! ! |
---|
669 | ! |
---|
670 | rhd (:,:,:) = 0.e0 |
---|
671 | rhop (:,:,:) = 0.e0 |
---|
672 | rn2 (:,:,:) = 0.e0 |
---|
673 | ! |
---|
674 | END SUBROUTINE istate_init |
---|
675 | |
---|
676 | SUBROUTINE stp_ctl( kt, kindic ) |
---|
677 | !!---------------------------------------------------------------------- |
---|
678 | !! *** ROUTINE stp_ctl *** |
---|
679 | !! |
---|
680 | !! ** Purpose : Control the run |
---|
681 | !! |
---|
682 | !! ** Method : - Save the time step in numstp |
---|
683 | !! |
---|
684 | !! ** Actions : 'time.step' file containing the last ocean time-step |
---|
685 | !!---------------------------------------------------------------------- |
---|
686 | INTEGER, INTENT(in ) :: kt ! ocean time-step index |
---|
687 | INTEGER, INTENT(inout) :: kindic ! indicator of solver convergence |
---|
688 | !!---------------------------------------------------------------------- |
---|
689 | ! |
---|
690 | IF( kt == nit000 .AND. lwp ) THEN |
---|
691 | WRITE(numout,*) |
---|
692 | WRITE(numout,*) 'stp_ctl : time-stepping control' |
---|
693 | WRITE(numout,*) '~~~~~~~' |
---|
694 | ! open time.step file |
---|
695 | CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) |
---|
696 | ENDIF |
---|
697 | ! |
---|
698 | IF(lwp) WRITE ( numstp, '(1x, i8)' ) kt !* save the current time step in numstp |
---|
699 | IF(lwp) REWIND( numstp ) ! -------------------------- |
---|
700 | ! |
---|
701 | END SUBROUTINE stp_ctl |
---|
702 | !!====================================================================== |
---|
703 | END MODULE nemogcm |
---|