-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdomain.F90
More file actions
620 lines (578 loc) · 33 KB
/
domain.F90
File metadata and controls
620 lines (578 loc) · 33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
MODULE domain
!!==============================================================================
!! *** MODULE domain ***
!! Ocean initialization : domain initialization
!!==============================================================================
!! History : OPA ! 1990-10 (C. Levy - G. Madec) Original code
!! ! 1992-01 (M. Imbard) insert time step initialization
!! ! 1996-06 (G. Madec) generalized vertical coordinate
!! ! 1997-02 (G. Madec) creation of domwri.F
!! ! 2001-05 (E.Durand - G. Madec) insert closed sea
!! NEMO 1.0 ! 2002-08 (G. Madec) F90: Free form and module
!! 2.0 ! 2005-11 (V. Garnier) Surface pressure gradient organization
!! 3.3 ! 2010-11 (G. Madec) initialisation in C1D configuration
!! 3.6 ! 2013 ( J. Simeon, C. Calone, G. Madec, C. Ethe ) Online coarsening of outputs
!!----------------------------------------------------------------------
!!----------------------------------------------------------------------
!! dom_init : initialize the space and time domain
!! dom_nam : read and contral domain namelists
!! dom_ctl : control print for the ocean domain
!!----------------------------------------------------------------------
USE oce ! ocean variables
USE dom_oce ! domain: ocean
USE sbc_oce ! surface boundary condition: ocean
USE phycst ! physical constants
USE closea ! closed seas
USE in_out_manager ! I/O manager
USE lib_mpp ! distributed memory computing library
USE domhgr ! domain: set the horizontal mesh
USE domzgr ! domain: set the vertical mesh
USE domstp ! domain: set the time-step
USE dommsk ! domain: set the mask system
USE domwri ! domain: write the meshmask file
USE domvvl ! variable volume
USE c1d ! 1D vertical configuration
USE dyncor_c1d ! Coriolis term (c1d case) (cor_c1d routine)
USE iom !
USE wrk_nemo ! Memory Allocation
USE timing ! Timing
USE lbclnk ! ocean lateral boundary condition (or mpp link)
IMPLICIT NONE
PRIVATE
PUBLIC dom_init ! called by opa.F90
!! * Substitutions
# include "domzgr_substitute.h90"
!!-------------------------------------------------------------------------
!! NEMO/OPA 3.3 , NEMO Consortium (2010)
!! $Id$
!! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
!!-------------------------------------------------------------------------
CONTAINS
SUBROUTINE dom_init
!!----------------------------------------------------------------------
!! *** ROUTINE dom_init ***
!!
!! ** Purpose : Domain initialization. Call the routines that are
!! required to create the arrays which define the space
!! and time domain of the ocean model.
!!
!! ** Method : - dom_msk: compute the masks from the bathymetry file
!! - dom_hgr: compute or read the horizontal grid-point position
!! and scale factors, and the coriolis factor
!! - dom_zgr: define the vertical coordinate and the bathymetry
!! - dom_stp: defined the model time step
!! - dom_wri: create the meshmask file if nmsh=1
!! - 1D configuration, move Coriolis, u and v at T-point
!!----------------------------------------------------------------------
INTEGER :: jk ! dummy loop argument
INTEGER :: iconf = 0 ! local integers
!!----------------------------------------------------------------------
!
IF( nn_timing == 1 ) CALL timing_start('dom_init')
!
IF(lwp) THEN
WRITE(numout,*)
WRITE(numout,*) 'dom_init : domain initialization'
WRITE(numout,*) '~~~~~~~~'
ENDIF
!
CALL dom_nam ! read namelist ( namrun, namdom, namcla )
CALL dom_clo ! Closed seas and lake
CALL dom_hgr ! Horizontal mesh
CALL dom_zgr ! Vertical mesh and bathymetry
CALL dom_msk ! Masks
IF( ln_sco ) CALL dom_stiff ! Maximum stiffness ratio/hydrostatic consistency
!
ht_0(:,:) = 0.0_wp ! Reference ocean depth at T-points
hu_0(:,:) = 0.0_wp ! Reference ocean depth at U-points
hv_0(:,:) = 0.0_wp ! Reference ocean depth at V-points
DO jk = 1, jpk
ht_0(:,:) = ht_0(:,:) + e3t_0(:,:,jk) * tmask(:,:,jk)
hu_0(:,:) = hu_0(:,:) + e3u_0(:,:,jk) * umask(:,:,jk)
hv_0(:,:) = hv_0(:,:) + e3v_0(:,:,jk) * vmask(:,:,jk)
END DO
!
IF( lk_vvl ) CALL dom_vvl_init ! Vertical variable mesh
!
IF( lk_c1d ) CALL cor_c1d ! 1D configuration: Coriolis set at T-point
!
!
hu(:,:) = 0._wp ! Ocean depth at U-points
hv(:,:) = 0._wp ! Ocean depth at V-points
ht(:,:) = 0._wp ! Ocean depth at T-points
DO jk = 1, jpkm1
hu(:,:) = hu(:,:) + fse3u_n(:,:,jk) * umask(:,:,jk)
hv(:,:) = hv(:,:) + fse3v_n(:,:,jk) * vmask(:,:,jk)
ht(:,:) = ht(:,:) + fse3t_n(:,:,jk) * tmask(:,:,jk)
END DO
! ! Inverse of the local depth
hur(:,:) = 1._wp / ( hu(:,:) + 1._wp - umask_i(:,:) ) * umask_i(:,:)
hvr(:,:) = 1._wp / ( hv(:,:) + 1._wp - vmask_i(:,:) ) * vmask_i(:,:)
CALL dom_stp ! time step
IF( nmsh /= 0 ) CALL dom_wri ! Create a domain file
IF( .NOT.ln_rstart ) CALL dom_ctl ! Domain control
CALL cfg_write ! create the configuration file
!
IF( nn_timing == 1 ) CALL timing_stop('dom_init')
!
END SUBROUTINE dom_init
SUBROUTINE dom_nam
!!----------------------------------------------------------------------
!! *** ROUTINE dom_nam ***
!!
!! ** Purpose : read domaine namelists and print the variables.
!!
!! ** input : - namrun namelist
!! - namdom namelist
!! - namcla namelist
!! - namnc4 namelist ! "key_netcdf4" only
!!----------------------------------------------------------------------
USE ioipsl
NAMELIST/namrun/ cn_ocerst_indir, cn_ocerst_outdir, nn_stocklist, ln_rst_list, &
& nn_no , cn_exp , cn_ocerst_in, cn_ocerst_out, ln_rstdate, ln_rstart , nn_rstctl, &
& nn_it000, nn_itend , nn_date0 , nn_leapy , nn_istate , nn_stock , &
& nn_write, ln_dimgnnn, ln_mskland , ln_cfmeta , ln_clobber, nn_chunksz, nn_euler
NAMELIST/namdom/ nn_bathy, rn_bathy , rn_e3zps_min, rn_e3zps_rat, nn_msh, rn_hmin, &
& nn_acc , rn_atfp , rn_rdt , rn_rdtmin , &
& rn_rdtmax, rn_rdth , nn_closea , ln_crs, &
& jphgr_msh, &
& ppglam0, ppgphi0, ppe1_deg, ppe2_deg, ppe1_m, ppe2_m, &
& ppsur, ppa0, ppa1, ppkth, ppacr, ppdzmin, pphmax, ldbletanh, &
& ppa2, ppkth2, ppacr2, rn_wd_ref_depth
NAMELIST/namcla/ nn_cla
#if defined key_netcdf4
NAMELIST/namnc4/ nn_nchunks_i, nn_nchunks_j, nn_nchunks_k, ln_nc4zip
#endif
INTEGER :: ios ! Local integer output status for namelist read
!!----------------------------------------------------------------------
REWIND( numnam_ref ) ! Namelist namrun in reference namelist : Parameters of the run
READ ( numnam_ref, namrun, IOSTAT = ios, ERR = 901)
901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namrun in reference namelist', lwp )
REWIND( numnam_cfg ) ! Namelist namrun in configuration namelist : Parameters of the run
READ ( numnam_cfg, namrun, IOSTAT = ios, ERR = 902 )
902 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namrun in configuration namelist', lwp )
IF(lwm) WRITE ( numond, namrun )
!
IF(lwp) THEN ! control print
WRITE(numout,*)
WRITE(numout,*) 'dom_nam : domain initialization through namelist read'
WRITE(numout,*) '~~~~~~~ '
WRITE(numout,*) ' Namelist namrun'
WRITE(numout,*) ' job number nn_no = ', nn_no
WRITE(numout,*) ' experiment name for output cn_exp = ', cn_exp
WRITE(numout,*) ' file prefix restart input cn_ocerst_in= ', cn_ocerst_in
WRITE(numout,*) ' restart input directory cn_ocerst_indir= ', cn_ocerst_indir
WRITE(numout,*) ' file prefix restart output cn_ocerst_out= ', cn_ocerst_out
WRITE(numout,*) ' restart output directory cn_ocerst_outdir= ', cn_ocerst_outdir
WRITE(numout,*) ' restart logical ln_rstart = ', ln_rstart
WRITE(numout,*) ' datestamping of restarts ln_rstdate = ', ln_rstdate
WRITE(numout,*) ' start with forward time step nn_euler = ', nn_euler
WRITE(numout,*) ' control of time step nn_rstctl = ', nn_rstctl
WRITE(numout,*) ' number of the first time step nn_it000 = ', nn_it000
WRITE(numout,*) ' number of the last time step nn_itend = ', nn_itend
WRITE(numout,*) ' initial calendar date aammjj nn_date0 = ', nn_date0
WRITE(numout,*) ' leap year calendar (0/1) nn_leapy = ', nn_leapy
WRITE(numout,*) ' initial state output nn_istate = ', nn_istate
IF( ln_rst_list ) THEN
WRITE(numout,*) ' list of restart dump times nn_stocklist =', nn_stocklist
ELSE
WRITE(numout,*) ' frequency of restart file nn_stock = ', nn_stock
ENDIF
WRITE(numout,*) ' frequency of output file nn_write = ', nn_write
WRITE(numout,*) ' multi file dimgout ln_dimgnnn = ', ln_dimgnnn
WRITE(numout,*) ' mask land points ln_mskland = ', ln_mskland
WRITE(numout,*) ' additional CF standard metadata ln_cfmeta = ', ln_cfmeta
WRITE(numout,*) ' overwrite an existing file ln_clobber = ', ln_clobber
WRITE(numout,*) ' NetCDF chunksize (bytes) nn_chunksz = ', nn_chunksz
ENDIF
no = nn_no ! conversion DOCTOR names into model names (this should disappear soon)
cexper = cn_exp
nrstdt = nn_rstctl
nit000 = nn_it000
nitend = nn_itend
ndate0 = nn_date0
nleapy = nn_leapy
ninist = nn_istate
nstock = nn_stock
nstocklist = nn_stocklist
nwrite = nn_write
neuler = nn_euler
IF ( neuler == 1 .AND. .NOT. ln_rstart ) THEN
WRITE(ctmp1,*) 'ln_rstart =.FALSE., nn_euler is forced to 0 '
CALL ctl_warn( ctmp1 )
neuler = 0
ENDIF
! ! control of output frequency
IF ( nstock == 0 .OR. nstock > nitend ) THEN
WRITE(ctmp1,*) 'nstock = ', nstock, ' it is forced to ', nitend
CALL ctl_warn( ctmp1 )
nstock = nitend
ENDIF
IF ( nwrite == 0 ) THEN
WRITE(ctmp1,*) 'nwrite = ', nwrite, ' it is forced to ', nitend
CALL ctl_warn( ctmp1 )
nwrite = nitend
ENDIF
#if defined key_agrif
IF( Agrif_Root() ) THEN
#endif
SELECT CASE ( nleapy ) ! Choose calendar for IOIPSL
CASE ( 1 )
CALL ioconf_calendar('gregorian')
IF(lwp) WRITE(numout,*) ' The IOIPSL calendar is "gregorian", i.e. leap year'
CASE ( 0 )
CALL ioconf_calendar('noleap')
IF(lwp) WRITE(numout,*) ' The IOIPSL calendar is "noleap", i.e. no leap year'
CASE ( 30 )
CALL ioconf_calendar('360d')
IF(lwp) WRITE(numout,*) ' The IOIPSL calendar is "360d", i.e. 360 days in a year'
END SELECT
#if defined key_agrif
ENDIF
#endif
REWIND( numnam_ref ) ! Namelist namdom in reference namelist : space & time domain (bathymetry, mesh, timestep)
READ ( numnam_ref, namdom, IOSTAT = ios, ERR = 903)
903 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namdom in reference namelist', lwp )
!
REWIND( numnam_cfg ) ! Namelist namdom in configuration namelist : space & time domain (bathymetry, mesh, timestep)
READ ( numnam_cfg, namdom, IOSTAT = ios, ERR = 904 )
904 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namdom in configuration namelist', lwp )
IF(lwm) WRITE ( numond, namdom )
IF(lwp) THEN
WRITE(numout,*)
WRITE(numout,*) ' Namelist namdom : space & time domain'
WRITE(numout,*) ' flag read/compute bathymetry nn_bathy = ', nn_bathy
WRITE(numout,*) ' Depth (if =0 bathy=jpkm1) rn_bathy = ', rn_bathy
WRITE(numout,*) ' WAD Reference depth) rn_wd_ref_depth = ', rn_wd_ref_depth
WRITE(numout,*) ' min depth of the ocean (>0) or rn_hmin = ', rn_hmin
WRITE(numout,*) ' min number of ocean level (<0) '
WRITE(numout,*) ' minimum thickness of partial rn_e3zps_min = ', rn_e3zps_min, ' (m)'
WRITE(numout,*) ' step level rn_e3zps_rat = ', rn_e3zps_rat
WRITE(numout,*) ' create mesh/mask file(s) nn_msh = ', nn_msh
WRITE(numout,*) ' = 0 no file created '
WRITE(numout,*) ' = 1 mesh_mask '
WRITE(numout,*) ' = 2 mesh and mask '
WRITE(numout,*) ' = 3 mesh_hgr, msh_zgr and mask'
WRITE(numout,*) ' ocean time step rn_rdt = ', rn_rdt
WRITE(numout,*) ' asselin time filter parameter rn_atfp = ', rn_atfp
WRITE(numout,*) ' acceleration of converge nn_acc = ', nn_acc
WRITE(numout,*) ' nn_acc=1: surface tracer rdt rn_rdtmin = ', rn_rdtmin
WRITE(numout,*) ' bottom tracer rdt rdtmax = ', rn_rdtmax
WRITE(numout,*) ' depth of transition rn_rdth = ', rn_rdth
WRITE(numout,*) ' suppression of closed seas (=0) nn_closea = ', nn_closea
WRITE(numout,*) ' online coarsening of dynamical fields ln_crs = ', ln_crs
WRITE(numout,*) ' type of horizontal mesh jphgr_msh = ', jphgr_msh
WRITE(numout,*) ' longitude of first raw and column T-point ppglam0 = ', ppglam0
WRITE(numout,*) ' latitude of first raw and column T-point ppgphi0 = ', ppgphi0
WRITE(numout,*) ' zonal grid-spacing (degrees) ppe1_deg = ', ppe1_deg
WRITE(numout,*) ' meridional grid-spacing (degrees) ppe2_deg = ', ppe2_deg
WRITE(numout,*) ' zonal grid-spacing (degrees) ppe1_m = ', ppe1_m
WRITE(numout,*) ' meridional grid-spacing (degrees) ppe2_m = ', ppe2_m
WRITE(numout,*) ' ORCA r4, r2 and r05 coefficients ppsur = ', ppsur
WRITE(numout,*) ' ppa0 = ', ppa0
WRITE(numout,*) ' ppa1 = ', ppa1
WRITE(numout,*) ' ppkth = ', ppkth
WRITE(numout,*) ' ppacr = ', ppacr
WRITE(numout,*) ' Minimum vertical spacing ppdzmin = ', ppdzmin
WRITE(numout,*) ' Maximum depth pphmax = ', pphmax
WRITE(numout,*) ' Use double tanf function for vertical coordinates ldbletanh = ', ldbletanh
WRITE(numout,*) ' Double tanh function parameters ppa2 = ', ppa2
WRITE(numout,*) ' ppkth2 = ', ppkth2
WRITE(numout,*) ' ppacr2 = ', ppacr2
ENDIF
ntopo = nn_bathy ! conversion DOCTOR names into model names (this should disappear soon)
e3zps_min = rn_e3zps_min
e3zps_rat = rn_e3zps_rat
nmsh = nn_msh
nacc = nn_acc
atfp = rn_atfp
rdt = rn_rdt
rdtmin = rn_rdtmin
rdtmax = rn_rdtmin
rdth = rn_rdth
REWIND( numnam_ref ) ! Namelist namcla in reference namelist : Cross land advection
READ ( numnam_ref, namcla, IOSTAT = ios, ERR = 905)
905 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namcla in reference namelist', lwp )
REWIND( numnam_cfg ) ! Namelist namcla in configuration namelist : Cross land advection
READ ( numnam_cfg, namcla, IOSTAT = ios, ERR = 906 )
906 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namcla in configuration namelist', lwp )
IF(lwm) WRITE( numond, namcla )
IF(lwp) THEN
WRITE(numout,*)
WRITE(numout,*) ' Namelist namcla'
WRITE(numout,*) ' cross land advection nn_cla = ', nn_cla
ENDIF
IF ( nn_cla .EQ. 1 ) THEN
IF ( cp_cfg == "orca" .AND. jp_cfg == 2 ) THEN ! ORCA R2
CONTINUE
ELSE
CALL ctl_stop( 'STOP', 'Cross land advation iplemented only for ORCA2 configuration: cp_cfg = "orca" and jp_cfg = 2 ' )
ENDIF
ENDIF
#if defined key_netcdf4
! ! NetCDF 4 case ("key_netcdf4" defined)
REWIND( numnam_ref ) ! Namelist namnc4 in reference namelist : NETCDF
READ ( numnam_ref, namnc4, IOSTAT = ios, ERR = 907)
907 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namnc4 in reference namelist', lwp )
REWIND( numnam_cfg ) ! Namelist namnc4 in configuration namelist : NETCDF
READ ( numnam_cfg, namnc4, IOSTAT = ios, ERR = 908 )
908 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namnc4 in configuration namelist', lwp )
IF(lwm) WRITE( numond, namnc4 )
IF(lwp) THEN ! control print
WRITE(numout,*)
WRITE(numout,*) ' Namelist namnc4 - Netcdf4 chunking parameters'
WRITE(numout,*) ' number of chunks in i-dimension nn_nchunks_i = ', nn_nchunks_i
WRITE(numout,*) ' number of chunks in j-dimension nn_nchunks_j = ', nn_nchunks_j
WRITE(numout,*) ' number of chunks in k-dimension nn_nchunks_k = ', nn_nchunks_k
WRITE(numout,*) ' apply netcdf4/hdf5 chunking & compression ln_nc4zip = ', ln_nc4zip
ENDIF
! Put the netcdf4 settings into a simple structure (snc4set, defined in in_out_manager module)
! Note the chunk size in the unlimited (time) dimension will be fixed at 1
snc4set%ni = nn_nchunks_i
snc4set%nj = nn_nchunks_j
snc4set%nk = nn_nchunks_k
snc4set%luse = ln_nc4zip
#else
snc4set%luse = .FALSE. ! No NetCDF 4 case
#endif
!
END SUBROUTINE dom_nam
SUBROUTINE dom_ctl
!!----------------------------------------------------------------------
!! *** ROUTINE dom_ctl ***
!!
!! ** Purpose : Domain control.
!!
!! ** Method : compute and print extrema of masked scale factors
!!----------------------------------------------------------------------
INTEGER :: iimi1, ijmi1, iimi2, ijmi2, iima1, ijma1, iima2, ijma2
INTEGER, DIMENSION(2) :: iloc !
REAL(wp) :: ze1min, ze1max, ze2min, ze2max
!!----------------------------------------------------------------------
!
IF(lk_mpp) THEN
CALL mpp_minloc( e1t(:,:), tmask_i(:,:), ze1min, iimi1,ijmi1 )
CALL mpp_minloc( e2t(:,:), tmask_i(:,:), ze2min, iimi2,ijmi2 )
CALL mpp_maxloc( e1t(:,:), tmask_i(:,:), ze1max, iima1,ijma1 )
CALL mpp_maxloc( e2t(:,:), tmask_i(:,:), ze2max, iima2,ijma2 )
ELSE
ze1min = MINVAL( e1t(:,:), mask = tmask_i(:,:) == 1._wp )
ze2min = MINVAL( e2t(:,:), mask = tmask_i(:,:) == 1._wp )
ze1max = MAXVAL( e1t(:,:), mask = tmask_i(:,:) == 1._wp )
ze2max = MAXVAL( e2t(:,:), mask = tmask_i(:,:) == 1._wp )
iloc = MINLOC( e1t(:,:), mask = tmask_i(:,:) == 1._wp )
iimi1 = iloc(1) + nimpp - 1
ijmi1 = iloc(2) + njmpp - 1
iloc = MINLOC( e2t(:,:), mask = tmask_i(:,:) == 1._wp )
iimi2 = iloc(1) + nimpp - 1
ijmi2 = iloc(2) + njmpp - 1
iloc = MAXLOC( e1t(:,:), mask = tmask_i(:,:) == 1._wp )
iima1 = iloc(1) + nimpp - 1
ijma1 = iloc(2) + njmpp - 1
iloc = MAXLOC( e2t(:,:), mask = tmask_i(:,:) == 1._wp )
iima2 = iloc(1) + nimpp - 1
ijma2 = iloc(2) + njmpp - 1
ENDIF
IF(lwp) THEN
WRITE(numout,*)
WRITE(numout,*) 'dom_ctl : extrema of the masked scale factors'
WRITE(numout,*) '~~~~~~~'
WRITE(numout,"(14x,'e1t maxi: ',1f10.2,' at i = ',i5,' j= ',i5)") ze1max, iima1, ijma1
WRITE(numout,"(14x,'e1t mini: ',1f10.2,' at i = ',i5,' j= ',i5)") ze1min, iimi1, ijmi1
WRITE(numout,"(14x,'e2t maxi: ',1f10.2,' at i = ',i5,' j= ',i5)") ze2max, iima2, ijma2
WRITE(numout,"(14x,'e2t mini: ',1f10.2,' at i = ',i5,' j= ',i5)") ze2min, iimi2, ijmi2
ENDIF
!
END SUBROUTINE dom_ctl
SUBROUTINE dom_stiff
!!----------------------------------------------------------------------
!! *** ROUTINE dom_stiff ***
!!
!! ** Purpose : Diagnose maximum grid stiffness/hydrostatic consistency
!!
!! ** Method : Compute Haney (1991) hydrostatic condition ratio
!! Save the maximum in the vertical direction
!! (this number is only relevant in s-coordinates)
!!
!! Haney, R. L., 1991: On the pressure gradient force
!! over steep topography in sigma coordinate ocean models.
!! J. Phys. Oceanogr., 21, 610???619.
!!----------------------------------------------------------------------
INTEGER :: ji, jj, jk
REAL(wp) :: zrxmax
REAL(wp), DIMENSION(4) :: zr1
!!----------------------------------------------------------------------
rx1(:,:) = 0.e0
zrxmax = 0.e0
zr1(:) = 0.e0
DO ji = 2, jpim1
DO jj = 2, jpjm1
DO jk = 1, jpkm1
zr1(1) = umask(ji-1,jj ,jk) *abs( (gdepw_0(ji ,jj ,jk )-gdepw_0(ji-1,jj ,jk ) &
& +gdepw_0(ji ,jj ,jk+1)-gdepw_0(ji-1,jj ,jk+1)) &
& /(gdepw_0(ji ,jj ,jk )+gdepw_0(ji-1,jj ,jk ) &
& -gdepw_0(ji ,jj ,jk+1)-gdepw_0(ji-1,jj ,jk+1) + rsmall) )
zr1(2) = umask(ji ,jj ,jk) *abs( (gdepw_0(ji+1,jj ,jk )-gdepw_0(ji ,jj ,jk ) &
& +gdepw_0(ji+1,jj ,jk+1)-gdepw_0(ji ,jj ,jk+1)) &
& /(gdepw_0(ji+1,jj ,jk )+gdepw_0(ji ,jj ,jk ) &
& -gdepw_0(ji+1,jj ,jk+1)-gdepw_0(ji ,jj ,jk+1) + rsmall) )
zr1(3) = vmask(ji ,jj ,jk) *abs( (gdepw_0(ji ,jj+1,jk )-gdepw_0(ji ,jj ,jk ) &
& +gdepw_0(ji ,jj+1,jk+1)-gdepw_0(ji ,jj ,jk+1)) &
& /(gdepw_0(ji ,jj+1,jk )+gdepw_0(ji ,jj ,jk ) &
& -gdepw_0(ji ,jj+1,jk+1)-gdepw_0(ji ,jj ,jk+1) + rsmall) )
zr1(4) = vmask(ji ,jj-1,jk) *abs( (gdepw_0(ji ,jj ,jk )-gdepw_0(ji ,jj-1,jk ) &
& +gdepw_0(ji ,jj ,jk+1)-gdepw_0(ji ,jj-1,jk+1)) &
& /(gdepw_0(ji ,jj ,jk )+gdepw_0(ji ,jj-1,jk ) &
& -gdepw_0(ji, jj ,jk+1)-gdepw_0(ji ,jj-1,jk+1) + rsmall) )
zrxmax = MAXVAL(zr1(1:4))
rx1(ji,jj) = MAX(rx1(ji,jj), zrxmax)
END DO
END DO
END DO
CALL lbc_lnk( rx1, 'T', 1. )
zrxmax = MAXVAL(rx1)
IF( lk_mpp ) CALL mpp_max( zrxmax ) ! max over the global domain
IF(lwp) THEN
WRITE(numout,*)
WRITE(numout,*) 'dom_stiff : maximum grid stiffness ratio: ', zrxmax
WRITE(numout,*) '~~~~~~~~~'
ENDIF
END SUBROUTINE dom_stiff
SUBROUTINE cfg_write
!!----------------------------------------------------------------------
!! *** ROUTINE cfg_write ***
!!
!! ** Purpose : Create the "domain_cfg" file, a NetCDF file which
!! contains all the ocean domain informations required to
!! define an ocean configuration.
!!
!! ** Method : Write in a file all the arrays required to set up an
!! ocean configuration.
!!
!! ** output file : domain_cfg.nc : domain size, characteristics,horizontal mesh,
!! Coriolis parameter, and vertical scale factors
!! NB: also contains ORCA family information (if cp_cfg = "ORCA")
!! and depths (ln_e3_dep=F)
!!----------------------------------------------------------------------
INTEGER :: ji, jj, jk ! dummy loop indices
INTEGER :: izco, izps, isco, icav
INTEGER :: inum ! temprary units for 'domain_cfg.nc' file
CHARACTER(len=21) :: clnam ! filename (mesh and mask informations)
REAL(wp), DIMENSION(jpi,jpj) :: z2d ! workspace
!!----------------------------------------------------------------------
!
IF(lwp) WRITE(numout,*)
IF(lwp) WRITE(numout,*) 'cfg_write : create the "domain_cfg.nc" file containing all required configuration information'
IF(lwp) WRITE(numout,*) '~~~~~~~~~'
!
! ! ============================= !
! ! create 'domain_cfg.nc' file !
! ! ============================= !
!
clnam = 'domain_cfg' ! filename (configuration information)
CALL iom_open( TRIM(clnam), inum, ldwrt = .TRUE., kiolib = jprstlib )
!
! !== ORCA family specificities ==!
IF( cp_cfg == "ORCA" ) THEN
CALL iom_rstput( 0, 0, inum, 'ORCA' , 1._wp , ktype = jp_i4 )
CALL iom_rstput( 0, 0, inum, 'ORCA_index', REAL( jp_cfg, wp), ktype = jp_i4 )
ENDIF
! !== global domain size ==!
!
CALL iom_rstput( 0, 0, inum, 'jpiglo', REAL( jpiglo, wp), ktype = jp_i4 )
CALL iom_rstput( 0, 0, inum, 'jpjglo', REAL( jpjglo, wp), ktype = jp_i4 )
CALL iom_rstput( 0, 0, inum, 'jpkglo', REAL( jpk , wp), ktype = jp_i4 )
!
! !== domain characteristics ==!
!
! ! lateral boundary of the global
! domain
CALL iom_rstput( 0, 0, inum, 'jperio', REAL( jperio, wp), ktype = jp_i4 )
!
! ! type of vertical coordinate
IF( ln_zco ) THEN ; izco = 1 ; ELSE ; izco = 0 ; ENDIF
IF( ln_zps ) THEN ; izps = 1 ; ELSE ; izps = 0 ; ENDIF
IF( ln_sco ) THEN ; isco = 1 ; ELSE ; isco = 0 ; ENDIF
CALL iom_rstput( 0, 0, inum, 'ln_zco' , REAL( izco, wp), ktype = jp_i4 )
CALL iom_rstput( 0, 0, inum, 'ln_zps' , REAL( izps, wp), ktype = jp_i4 )
CALL iom_rstput( 0, 0, inum, 'ln_sco' , REAL( isco, wp), ktype = jp_i4 )
!
! ! ocean cavities under iceshelves
IF( ln_isfcav ) THEN ; icav = 1 ; ELSE ; icav = 0 ; ENDIF
CALL iom_rstput( 0, 0, inum, 'ln_isfcav', REAL( icav, wp), ktype = jp_i4 )
!
! !== horizontal mesh !
!
CALL iom_rstput( 0, 0, inum, 'hbatt', hbatt ) ! hbatt
!CEOD Just force it to be this for now
z2d(:,:) = hbatt(:,:) ! add back on reference height to get appox dep
!this is later corrected for with specified min depth bg user for above greoid
! WAD points
!where (z2d (:,:).lte.1e-5) z2d(:,:) = -10.0
where (tmask (:,:,1).eq.0) z2d(:,:) = 0.0
!CEOD CALL iom_rstput( 0, 0, inum, 'rn_wd_ref_depth' , rn_wd_ref_depth, ktype = jp_i4 ) ! replace this later with variable
CALL iom_rstput( 0, 0, inum, 'rn_wd_ref_depth' , rn_wd_ref_depth ) ! replace this later with variable
CALL iom_rstput( 0, 0, inum, 'ht_wd', z2d ) ! ht_wd
!CEOD
CALL iom_rstput( 0, 0, inum, 'glamt', glamt, ktype = jp_r8 ) ! latitude
CALL iom_rstput( 0, 0, inum, 'glamu', glamu, ktype = jp_r8 )
CALL iom_rstput( 0, 0, inum, 'glamv', glamv, ktype = jp_r8 )
CALL iom_rstput( 0, 0, inum, 'glamf', glamf, ktype = jp_r8 )
!
CALL iom_rstput( 0, 0, inum, 'gphit', gphit, ktype = jp_r8 ) ! longitude
CALL iom_rstput( 0, 0, inum, 'gphiu', gphiu, ktype = jp_r8 )
CALL iom_rstput( 0, 0, inum, 'gphiv', gphiv, ktype = jp_r8 )
CALL iom_rstput( 0, 0, inum, 'gphif', gphif, ktype = jp_r8 )
!
CALL iom_rstput( 0, 0, inum, 'e1t' , e1t , ktype = jp_r8 ) ! i-scale factors (e1.)
CALL iom_rstput( 0, 0, inum, 'e1u' , e1u , ktype = jp_r8 )
CALL iom_rstput( 0, 0, inum, 'e1v' , e1v , ktype = jp_r8 )
CALL iom_rstput( 0, 0, inum, 'e1f' , e1f , ktype = jp_r8 )
!
CALL iom_rstput( 0, 0, inum, 'e2t' , e2t , ktype = jp_r8 ) ! j-scale factors (e2.)
CALL iom_rstput( 0, 0, inum, 'e2u' , e2u , ktype = jp_r8 )
CALL iom_rstput( 0, 0, inum, 'e2v' , e2v , ktype = jp_r8 )
CALL iom_rstput( 0, 0, inum, 'e2f' , e2f , ktype = jp_r8 )
!
CALL iom_rstput( 0, 0, inum, 'ff_f' , ff_f , ktype = jp_r8 ) ! coriolis factor
CALL iom_rstput( 0, 0, inum, 'ff_t' , ff_t , ktype = jp_r8 )
!
! !== vertical mesh ==!
!
CALL iom_rstput( 0, 0, inum, 'e3t_1d' , e3t_1d , ktype = jp_r8 ) ! reference 1D-coordinate
CALL iom_rstput( 0, 0, inum, 'e3w_1d' , e3w_1d , ktype = jp_r8 )
!
CALL iom_rstput( 0, 0, inum, 'e3t_0' , e3t_0 , ktype = jp_r8 ) ! vertical scale factors (e
CALL iom_rstput( 0, 0, inum, 'e3u_0' , e3u_0 , ktype = jp_r8 )
CALL iom_rstput( 0, 0, inum, 'e3v_0' , e3v_0 , ktype = jp_r8 )
CALL iom_rstput( 0, 0, inum, 'e3f_0' , e3f_0 , ktype = jp_r8 )
CALL iom_rstput( 0, 0, inum, 'e3w_0' , e3w_0 , ktype = jp_r8 )
CALL iom_rstput( 0, 0, inum, 'e3uw_0' , e3uw_0 , ktype = jp_r8 )
CALL iom_rstput( 0, 0, inum, 'e3vw_0' , e3vw_0 , ktype = jp_r8 )
!
!CEOD IF(.NOT.ln_e3_dep ) THEN ! depth (t- & w-points)
CALL iom_rstput( 0, 0, inum, 'gdept_1d', gdept_1d, ktype = jp_r8 ) ! required only with
CALL iom_rstput( 0, 0, inum, 'gdepw_1d', gdepw_1d, ktype = jp_r8 ) ! the old e3. definition
CALL iom_rstput( 0, 0, inum, 'gdept_0' , gdept_0 , ktype = jp_r8 )
CALL iom_rstput( 0, 0, inum, 'gdepw_0' , gdepw_0 , ktype = jp_r8 )
!CEOD ENDIF
!
! !== ocean top and bottom level ==!
!
CALL iom_rstput( 0, 0, inum, 'bottom_level' , REAL( mbkt, wp )*ssmask , ktype = jp_i4 ) ! nb of ocean T-points
CALL iom_rstput( 0, 0, inum, 'top_level' , REAL( mikt, wp )*ssmask , ktype = jp_i4 ) ! nb of ocean T-points (ISF)
!
IF( ln_sco ) THEN ! s-coordinate: store grid stiffness ratio (Not required anyway)
CALL dom_stiff_tool( z2d )
CALL iom_rstput( 0, 0, inum, 'stiffness', z2d ) ! ! Max. grid stiffness ratio
ENDIF
!
! ! ============================
! ! close the files
! ! ============================
CALL iom_close( inum )
!
END SUBROUTINE cfg_write
!!======================================================================
!!======================================================================
END MODULE domain