My Project
mod_setup.f90
Go to the documentation of this file.
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 !/===========================================================================/
13 ! Copyright (c) 2007, The University of Massachusetts Dartmouth
14 ! Produced at the School of Marine Science & Technology
15 ! Marine Ecosystem Dynamics Modeling group
16 ! All rights reserved.
17 !
18 ! FVCOM has been developed by the joint UMASSD-WHOI research team. For
19 ! details of authorship and attribution of credit please see the FVCOM
20 ! technical manual or contact the MEDM group.
21 !
22 !
23 ! This file is part of FVCOM. For details, see http://fvcom.smast.umassd.edu
24 ! The full copyright notice is contained in the file COPYRIGHT located in the
25 ! root directory of the FVCOM code. This original header must be maintained
26 ! in all distributed versions.
27 !
28 ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29 ! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
30 ! THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31 ! PURPOSE ARE DISCLAIMED.
32 !
33 !/---------------------------------------------------------------------------/
34 ! CVS VERSION INFORMATION
35 ! $Id$
36 ! $Name$
37 ! $Revision$
38 !/===========================================================================/
39 
40 MODULE mod_setup
41  USE all_vars
42  USE mod_par
43  USE mod_input
44  USE mod_ncdio
45  USE mod_nctools
46  USE mod_utils
47  USE mod_obcs
48  USE mod_force
49 
50  IMPLICIT NONE
51 
52  SAVE
53  ! COORDINATE VARIABLES
54  REAL(sp), ALLOCATABLE, TARGET :: x_gbl(:),y_gbl(:)
55  REAL(sp), ALLOCATABLE, TARGET :: x_lcl(:),y_lcl(:)
56 
57  ! CORIOLIS VARIABLES
58  REAL(sp), ALLOCATABLE, TARGET :: c_lcl(:) !!CORIOLIS PARAMETER AT NODES
59 
60  ! DEPTH VARIABLE
61  REAL(sp), ALLOCATABLE, TARGET :: h_lcl(:) !! DEPTH PARAMETER AT NODES
62 
63  ! SPONGE LAYER VARIABLE
64  INTEGER, ALLOCATABLE, TARGET :: n_spg(:)
65  REAL(sp), ALLOCATABLE, TARGET :: r_spg(:),c_spg(:),x_spg(:),y_spg(:)
66  INTEGER :: nsponge
67 
68  PRIVATE :: sigma_geometric, sigma_generalized, sigma_tanh
69 
70 CONTAINS
71 
72 !==============================================================================!
73  SUBROUTINE setup_center_coords
75  IMPLICIT NONE
76  INTEGER I,J,IERR,STATUS,SENDID
77  REAL(SP) SBUF
78 
79  INTEGER K,ITMP
80  REAL(DP) VX1,VY1,VX2,VY2,VX3,VY3
81  REAL(DP) EVX12,EVX13,EVX23,EVY12,EVY13,EVY23,EVXY
82  REAL(DP) VX12,VY12,VX23,VY23,VX31,VY31
83  INTEGER :: SENDER
84 
85  ! David Added:
86  REAL(SP), allocatable :: xc_buf(:), lonc_buf(:)
87  REAL(SP), allocatable :: yc_buf(:), latc_buf(:)
88 
89  IF(dbg_set(dbg_sbr)) write(ipt,*) "SETUP_CENTER_COORDS: START"
90 
91 
92 !==============================================================================|
93 ! SET UP LOCAL MESH (HORIZONTAL COORDINATES) |
94 !==============================================================================|
95 !--------------CALCULATE GLOBAL MINIMUMS AND MAXIMUMS--------------------------!
96 
97 ! IF THIS IS NOT A SPHERICAL MODEL REMOVE MIN COORDINATE VALUE
98 
99  vxmin = minval(vx(1:mt)) ; vxmax = maxval(vx(1:mt))
100  vymin = minval(vy(1:mt)) ; vymax = maxval(vy(1:mt))
101 
102  !--------------SHIFT GRID TO UPPER RIGHT CARTESIAN-----------------------------!
103 
104  vx = vx - vxmin
105  vy = vy - vymin
106  vx(0) = 0.0_sp ; vy(0) = 0.0_sp
107 
108  !--------------CALCULATE GLOBAL ELEMENT CENTER GRID COORDINATES----------------!
109  CALL n2e2d(vx,xc)
110  CALL n2e2d(vy,yc)
111 
112  xmc = xc + vxmin
113  xmc(0)= 0.0_sp
114  ymc = yc + vymin
115  ymc(0)= 0.0_sp
116 
117  IF (use_proj ) THEN
118  IF (serial) THEN
119  CALL meters2degrees(xmc(1:nt),ymc(1:nt)&
120  & ,projection_reference,lonc(1:nt),latc(1:nt),nt)
121  END IF
122 
123  END IF
124 
125 
126 
127  IF(dbg_set(dbg_sbr)) write(ipt,*) "SETUP_CENTER_COORDS: END"
128 
129  END SUBROUTINE setup_center_coords
130  !==============================================================================|
131  ! SET HORIZONTAL MIXING_COEFFICIENT |
132  !==============================================================================|
134  IMPLICIT NONE
135 
136  if (horizontal_mixing_kind .eq. sttc) THEN
137 
138  if(dbg_set(dbg_log)) then
139  write(ipt,*) "! "
140  write(ipt,*) "! Setting Staticly Variable viscosity"
141  end if
142 
144 
145 
146  else if(horizontal_mixing_kind .eq. cnstnt) THEN
147 
148  cc_hvc=horizontal_mixing_coefficient
149  cc_hvc(0)=0.0_sp
150  nn_hvc=horizontal_mixing_coefficient
151  nn_hvc(0)=0.0_sp
152 
153  else
154  CALL fatal_error&
155  &("HORIZONTAL_MIXING_KIND ERROR",&
156  & "This should not happen")
157 
158  end if
159 
160 
162  !==============================================================================|
163  ! SET BOTTOM ROUGHNESS |
164  !==============================================================================|
165  SUBROUTINE setup_bottom_roughness
166  IMPLICIT NONE
167 
168  if (bottom_roughness_kind .eq. sttc) THEN
169 
170  if(dbg_set(dbg_log)) then
171  write(ipt,*) "! "
172  write(ipt,*) "! Setting Staticly Variable Bottom Roughness"
173  end if
174 
176 
177  else if(bottom_roughness_kind .eq. cnstnt) THEN
178 
179  cc_z0b = bottom_roughness_lengthscale
180  cc_z0b(0) = 0.0_sp
181 
182  else
183  CALL fatal_error&
184  &("HORIZONTAL_MIXING_KIND ERROR",&
185  & "This should not happen")
186 
187  end if
188 
189 
190  END SUBROUTINE setup_bottom_roughness
191  !==============================================================================|
192  ! SET UP LOCAL MESH (BATHYMETRIC DEPTH) |
193  !==============================================================================|
194  SUBROUTINE setup_depth
195  IMPLICIT NONE
196  INTEGER :: IERR
197  REAL(SP):: SBUF
198 
199  IF(dbg_set(dbg_sbr)) write(ipt,*) "SETUP_DEPTH: START"
200  hmax = maxval(h_lcl(1:mt))
201  hmin = minval(h_lcl(1:mt))
202 
203 
204  h = h_lcl
205 
206  IF(dbg_set(dbg_sbr)) write(ipt,*) "SETUP_DEPTH: END"
207 
208  END SUBROUTINE setup_depth
209 
210 !==============================================================================|
211 ! SET UP LOCAL CORIOLIS FORCE |
212 !==============================================================================|
213  SUBROUTINE setup_coriolis
214  IMPLICIT NONE
215  integer:: I
216  !--------------READ IN CORIOLIS PARAMETER--------------------------------------!
217 
218  IF(dbg_set(dbg_sbr)) write(ipt,*) "SETUP_CORIOLIS: START"
219 
220  CALL n2e2d(c_lcl,cor)
221 
222 
223  cor = 2.*7.292e-5_sp * sin(cor * deg2rad)
224 
225  !! ggao for equatoral min (4deg)
226  IF(.NOT. equator_beta_plane)THEN
227  WHERE(cor < 1.e-5_sp .AND. cor > 0.0_sp) cor = 1.e-5_sp
228  WHERE(cor > -1.e-5_sp .AND. cor < 0.0_sp) cor = -1.e-5_sp
229  END IF
230 
231  IF(dbg_set(dbg_sbr)) write(ipt,*) "SETUP_CORIOLIS: END"
232 
233  END SUBROUTINE setup_coriolis
234 
235 
236 !==============================================================================|
237 ! COMPUTE GRAVITY VARIED WITH LATITUDE |
238 !==============================================================================|
239 
240  SUBROUTINE setup_gravity
241  IMPLICIT NONE
242  INTEGER I
243 
244  IF(dbg_set(dbg_sbr)) write(ipt,*) "SETUP_GRAVITY: START"
245 
246  grav_n = grav
247  grav_e = grav
248 
249  IF(dbg_set(dbg_sbr)) write(ipt,*) "SETUP_GRAVITY: END"
250  END SUBROUTINE setup_gravity
251 
252 !==============================================================================|
253 ! COMPUTE SPONGE LAYER FOR OPEN BOUNDARY DAMPING |
254 !==============================================================================|
255 
256  SUBROUTINE setup_sponge
258  IMPLICIT NONE
259  REAL(SP) TEMP,DTMP,C_SPONGE
260  INTEGER :: I1, I, SENDER, IERR
261  REAL(DP) X1_DP,Y1_DP,X2_DP,Y2_DP,DTMP_DP
262 
263  !--SET SPONGE PARAMETERS-------------------------------------------------------|
264 
265  IF(dbg_set(dbg_sbr)) write(ipt,*) "SETUP_SPONGE: START"
266 
267  IF (nsponge ==0) RETURN
268 
269 ! NOTE: X_SPG/Y_SPG COORDINATES MUST BE AJUSTED FOR VXMIN/VYMIN
270 
271  x_spg = x_spg - vxmin
272  y_spg = y_spg - vymin
273 
274  DO i=1,nt
275  DO i1=1,nsponge
276  dtmp=(xc(i)-x_spg(i1))**2+(yc(i)-y_spg(i1))**2
277  dtmp=sqrt(dtmp)/r_spg(i1)
278 
279  IF(dtmp <= 1.0_sp) THEN
280  c_sponge=c_spg(i1)*(1.0_sp-dtmp)
281  cc_sponge(i)=max(c_sponge,cc_sponge(i))
282  END IF
283  END DO
284  END DO
285 
286 
287  DEALLOCATE(n_spg,r_spg,c_spg,x_spg,y_spg)
288 
289  IF(dbg_set(dbg_sbr)) write(ipt,*) "SETUP_SPONGE: END"
290 
291  RETURN
292  END SUBROUTINE setup_sponge
293 !==============================================================================|
294 
295 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%|
296 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%|
297 
298 !==============================================================================|
299  SUBROUTINE coordinate_units(XL,YL)
300  IMPLICIT NONE
301  REAL(SP), ALLOCATABLE :: XL(:),YL(:)
302  integer status, ierr
303 
304 
305  REAL(SP), allocatable :: x_buf(:), lon_buf(:)
306  REAL(SP), allocatable :: y_buf(:), lat_buf(:)
307 
308  IF(dbg_set(dbg_sbr)) write(ipt,*) "COODINATE_UNITS: START"
309 
310 !! IF NOT SPHERICAL CASE
311 
312  IF (grid_file_units == 'degrees') THEN
313 
314  IF (use_proj) THEN
315 
316  lon = xl
317  lat = yl
318 
319  ! USE PROJECTION TOOL BOX TO CONVERT TO METERS
320  IF (serial) THEN
321  CALL degrees2meters(xl(1:mt),yl(1:mt), &
322  & projection_reference,vx(1:mt),vy(1:mt),mt)
323  END IF
324  xm = vx
325  ym = vy
326 
327  ELSE
328 
329  CALL fatal_error('You must specify a valid projection reference'&
330  &,'and compile with PROJ to use files with latitude and longitue in cartesian mode')
331  END IF
332 
333 
334  ELSE IF(grid_file_units == 'meters') THEN
335 
336  vx = xl
337  vy = yl
338 
339  xm = xl
340  ym = yl
341 
342  ! USE PROJECTION TOOL BOX TO CONVERT TO DEGREES
343  IF (use_proj ) THEN
344  IF (serial) THEN
345  CALL meters2degrees(xl(1:mt),yl(1:mt), &
346  & projection_reference,lon(1:mt),lat(1:mt),mt)
347  END IF
348 
349  END IF
350 
351  ELSE
352  CALL fatal_error('UNRECOGNIZED GRID_FILE_UNITS: '//trim(grid_file_units))
353 
354  END IF
355 
356 
357  IF(dbg_set(dbg_sbr)) write(ipt,*) "COODINATE_UNITS: END"
358 
359  END SUBROUTINE coordinate_units
360 
361 !==============================================================================|
362 ! SETUP THE SIGMA COORDINATES FOR THE MODEL |
363 !==============================================================================|
364 !==============================================================================|
365 ! This program is used to set up the coordinate in the vertical. !
366 ! !
367 ! case(1): sigma levels !
368 ! sigma levels are determined by a formula of !
369 ! sigma(k)=-[(k-1)/(kb-1)]^k11 !
370 ! p_sigma=1: uniform sigma layers !
371 ! p_sigma=2: layers satisfying a parabolic function with high !
372 ! vertical resolution near the surface and bottom. !
373 ! p_sigma can be used any real number !
374 ! !
375 ! case(2): general vertical level !
376 ! vertical levels are determined by the formula !
377 ! tanh[(dl+du)((kbm1-k)/kbm1)-dl]+tanh(dl) !
378 ! z(k)= ------------------------------------------ - 1 !
379 ! tanh(dl) + tanh(du) !
380 ! !
381 ! case(3): constant layer transformation !
382 ! four values need to be specified: !
383 ! DUU the upper boundaries, up to which the co-ordinates are parallel must be !
384 ! defined. !
385 ! DLL the lower boundaries, up to which the co-ordinates are parallel must be !
386 ! defined. !
387 ! HMIN1 the minimum water depth at which the layers are constant. If H < HMIN1!
388 ! then sigma co-ordinates are used. !
389 ! !
390 ! Reference of case(2), case(3) and case(4): !
391 ! Pietrzak, J.D., Jan B. Jakobson, Hans Burchard, Hans Jacob Vested, Ole !
392 ! Petersen , 2002. A three-dimensional hydrostatic model for coastal and ocean !
393 ! modelling using a generalised topography following co-ordinate system. Ocean !
394 ! Modelling 4, 173-205 !
395 ! !
396 ! calculates: z(m,kb) vertical levels !
397 ! calculates: dz(m,kb-1) delta between vertical levels !
398 ! calculates: zz(m,kb-1) intra-vertical levels !
399 ! calculates: dzz(m,kb-2) delta between intra-vertical levels !
400 !==============================================================================|
401 
402  SUBROUTINE setup_sigma
403  !==============================================================================|
404  IMPLICIT NONE
405  INTEGER :: K,KK
406  INTEGER :: I
407  REAL(SP):: ZTMP(KB)
408  REAL(SP):: X1,X2,X3
409  REAL(SP):: DR,RCL,RCU
410  !==============================================================================|
411 
412  IF(dbg_set(dbg_sbr)) WRITE(ipt,*)"SETUP_SIGMA: START"
413 
414  IF(dbg_set(dbg_sbrio)) THEN
415  WRITE(ipt,*)"==================="
416  WRITE(ipt,*)" SET_SIGMA IO"
417  WRITE(ipt,*)" STYPE = "//trim(stype)
418  WRITE(ipt,*)" P_SIGMA = ", p_sigma
419  WRITE(ipt,*)" KB = ", kb
420  WRITE(ipt,*)"==================="
421  END IF
422 
423  !---------------------------------------------
424  !---------------------------------------------
425  SELECT CASE(stype)
426  !---------------------------------------------
427  !SIGMA_COORDINATE_TYPE = UNIFORM (DEGENERATE CASE OF GEOMETRIC)
428  CASE(stype_uniform)
429  !---------------------------------------------
430  IF(p_sigma > 1 .AND. mod(kb,2) == 0) &
431  CALL fatal_error('SETUP_SIGMA: COORDINATE TYPE:'//trim(stype)&
432  &,'kb shoude be an odd number for this type of sigma coordinates....' )
433  CALL sigma_geometric
434  !---------------------------------------------
435  !SIGMA_COORDINATE_TYPE = GEOMETRIC
436  CASE(stype_geometric)
437  !---------------------------------------------
438 
439  IF(p_sigma > 1 .AND. mod(kb,2) == 0) &
440  CALL fatal_error('SETUP_SIGMA: COORDINATE TYPE:'//trim(stype)&
441  &,'kb shoude be an odd number for this type of sigma coordinates....' )
442  CALL sigma_geometric
443  !---------------------------------------------
444  ! SIGMA_COORDINATE_TYPE = TANH
445  CASE(stype_tanh)
446  !---------------------------------------------
447  CALL sigma_tanh
448  !---------------------------------------------
449  !SIGMA_COORDINATE_TYPE = GENERALIZED
450  CASE(stype_generalized)
451  !---------------------------------------------
452  CALL sigma_generalized
453 
454  ! THIS IS A CURRENTLY UNUSED METHOD
455 !!$!---------------------------------------------
456 !!$!SIGMA_COORDINATE_TYPE = WHAT THE HELL IS THIS?
457 !!$ CASE("UNKNOWN")
458 !!$!---------------------------------------------
459 !!$
460 !!$ CALL SIGMA_UNKNOWN
461  CASE DEFAULT
462  CALL fatal_error("SET_SIGMA: REACHED DEFAULT CASE FOR SIGMA COOR&
463  &DINATE TYPE")
464  END SELECT
465 
466  !---------COMPUTE SIGMA DERIVATIVES AND INTRA SIGMA LEVELS---------------------!
467 
468  IF(dbg_set(dbg_sbr)) WRITE(ipt,*)"SETUP_SIGMA: END"
469 
470  RETURN
471 
472  END SUBROUTINE setup_sigma
473 !==============================================================================|
474  SUBROUTINE sigma_geometric
475  IMPLICIT NONE
476  INTEGER :: I,K
477  REAL(SP):: ZTMP(KB)
478  !orginal formula to set sigma
479  IF(p_sigma == 1)THEN
480  DO k=1,kb
481  ztmp(k) = -((k-1)/float(kb-1))**p_sigma
482  END DO
483  ELSE
484  DO k=1,(kb+1)/2
485  ztmp(k) = -((k-1)/float((kb+1)/2-1))**p_sigma/2
486  END DO
487  DO k=(kb+1)/2+1,kb
488  ztmp(k) = ((kb-k)/float((kb+1)/2-1))**p_sigma/2-1.0
489  END DO
490  END IF
491 
492  DO i=1,m
493  DO k=1,kb
494  z(i,k)=ztmp(k)
495  END DO
496  END DO
497 
498  DO i=1,n
499  DO k=1,kb
500  z1(i,k)=(z(nv(i,1),k)+z(nv(i,2),k)+z(nv(i,3),k))/3.0_sp
501  END DO
502  END DO
503  END SUBROUTINE sigma_geometric
504 !--------------------------------------------------------------------
505  SUBROUTINE sigma_generalized
506  IMPLICIT NONE
507  INTEGER :: I,K, kk
508  REAL(SP):: X1,X2,X3
509  REAL(SP):: DR,RCL,RCU
510 
511  DO i=1,m
512  IF(h(i) < hmin1)THEN
513  z(i,1)=0.0
514  dl2=0.001;du2=0.001
515  DO k=1,kbm1
516  x1=dl2+du2
517  x1=x1*(kbm1-k)/kbm1
518  x1=x1-dl2
519  x1=tanh(x1)
520  x2=tanh(dl2)
521  x3=x2+tanh(du2)
522 
523  z(i,k+1)=(x1+x2)/x3-1.0_sp
524  END DO
525  ELSE
526  dr=(h(i)-duu-dll)/h(i)/(kb-ku-kl-1)
527 
528  z(i,1)=0.0_sp
529 
530  DO k=2,ku+1
531  z(i,k)=z(i,k-1)-zku(k-1)/h(i)
532  END DO
533 
534  DO k=ku+2,kb-kl
535  z(i,k)=z(i,k-1)-dr
536  END DO
537 
538  kk=0
539  DO k=kb-kl+1,kb
540  kk=kk+1
541  z(i,k)=z(i,k-1)-zkl(kk)/h(i)
542  END DO
543  END IF
544  END DO
545 
546  DO i=1,n
547  DO k=1,kb
548  z1(i,k)=(z(nv(i,1),k)+z(nv(i,2),k)+z(nv(i,3),k))/3.0_sp
549  END DO
550  END DO
551  END SUBROUTINE sigma_generalized
552 !--------------------------------------------------------------------
553  SUBROUTINE sigma_tanh
554  IMPLICIT NONE
555  INTEGER :: I,K
556  REAL(SP):: X1,X2,X3
557 
558  z=0.0;z1=0.0
559  DO k=1,kbm1
560  x1=dl2+du2
561  x1=x1*(kbm1-k)/kbm1
562  x1=x1-dl2
563  x1=tanh(x1)
564  x2=tanh(dl2)
565  x3=x2+tanh(du2)
566  DO i=1,m
567  z(i,k+1)=(x1+x2)/x3-1.0_sp
568  END DO
569  DO i=1,n
570  z1(i,k+1)=(x1+x2)/x3-1.0_sp
571  END DO
572  END DO
573  END SUBROUTINE sigma_tanh
574 !--------------------------------------------------------------------
575 !!$ SUBROUTINE SIGMA_UNKNOWN
576 !!$ DO I=1,M
577 !!$ IF(H(I) < HMIN1)THEN
578 !!$ RCU=-DUU/HMIN1
579 !!$ RCL=DLL/HMIN1-1
580 !!$ DR=(RCL-RCU)/(KB-KU-KL-1)
581 !!$
582 !!$ DO K=1,KU
583 !!$ ZKU(K)=RCU/KU
584 !!$ END DO
585 !!$ DO K=1,KL
586 !!$ ZKL(K)=(-1.0_SP-RCL)/KL
587 !!$ END DO
588 !!$
589 !!$ Z(I,1)=0.0_SP
590 !!$
591 !!$ DO K=2,KU+1
592 !!$ Z(I,K)=Z(I,K-1)+ZKU(K-1)
593 !!$ END DO
594 !!$
595 !!$ DO K=KU+2,KB-KL
596 !!$ Z(I,K)=Z(I,K-1)+DR
597 !!$ END DO
598 !!$
599 !!$ KK=0
600 !!$ DO K=KB-KL+1,KB
601 !!$ KK=KK+1
602 !!$ Z(I,K)=Z(I,K-1)+ZKL(KK)
603 !!$ END DO
604 !!$
605 !!$ ELSE
606 !!$ DR=(H(I)-DUU-DLL)/H(I)/(KB-KU-KL-1)
607 !!$
608 !!$ Z(I,1)=0.0_SP
609 !!$
610 !!$ DO K=2,KU+1
611 !!$ Z(I,K)=Z(I,K-1)-ZKU(K-1)/H(I)
612 !!$ END DO
613 !!$
614 !!$ DO K=KU+2,KB-KL
615 !!$ Z(I,K)=Z(I,K-1)-DR
616 !!$ END DO
617 !!$
618 !!$ KK=0
619 !!$ DO K=KB-KL+1,KB
620 !!$ KK=KK+1
621 !!$ Z(I,K)=Z(I,K-1)-ZKL(KK)/H(I)
622 !!$ END DO
623 !!$ END IF
624 !!$ END DO
625 !!$
626 !!$ DO I=1,N
627 !!$ DO K=1,KB
628 !!$ Z1(I,K)=(Z(NV(I,1),K)+Z(NV(I,2),K)+Z(NV(I,3),K))/3.0_SP
629 !!$ END DO
630 !!$ END DO
631 !!$END SUBROUTINE SIGMA_UNKNOWN
632 
633 !==============================================================================|
634 
635  SUBROUTINE setup_sigma_derivatives
637  IMPLICIT NONE
638  INTEGER :: K, I
639 
640 
641  IF(dbg_set(dbg_sbr)) WRITE(ipt,*)"SETUP_SIGMA_DERIVATIVES: START"
642 
643  DO k=1,kb-1
644  DO i=1,mt
645  dz(i,k) = z(i,k)-z(i,k+1)
646  zz(i,k) = .5_sp*(z(i,k)+z(i,k+1))
647  END DO
648  DO i=1,nt
649  dz1(i,k) = z1(i,k)-z1(i,k+1)
650  zz1(i,k) = .5_sp*(z1(i,k)+z1(i,k+1))
651  END DO
652  END DO
653 
654  DO i=1,mt
655  zz(i,kb) = 2.0_sp*zz(i,kb-1)-zz(i,kb-2)
656  END DO
657  DO i=1,nt
658  zz1(i,kb) = 2.0_sp*zz1(i,kb-1)-zz1(i,kb-2)
659  END DO
660 
661  DO k=1,kbm2
662  DO i=1,mt
663  dzz(i,k) = zz(i,k)-zz(i,k+1)
664  END DO
665  DO i=1,nt
666  dzz1(i,k) = zz1(i,k)-zz1(i,k+1)
667  END DO
668  END DO
669 
670  dzz(:,kbm1) = 0.0_sp
671  dz(:,kb) = 0.0_sp
672  dzz1(:,kbm1) = 0.0_sp
673  dz1(:,kb) = 0.0_sp
674 
675 
676  !----------OUTPUT VALUES-TO INFOFILE-------------------------------------------!
677 
678  IF(dbg_set(dbg_log)) THEN
679  WRITE(ipt,* )'!'
680  WRITE(ipt,* )'!'
681  WRITE(ipt,*)'! SIGMA LAYER INFO '
682  WRITE(ipt,*) "SIGMA TYPE:",trim(stype)
683  WRITE(ipt,70)
684  SELECT CASE(stype)
685  CASE(stype_uniform)
686  DO k=1,kb
687  WRITE(ipt,80) k,z(1,k),zz(1,k),dz(1,k),dzz(1,k)
688  END DO
689  CASE(stype_restart)
690  DO k=1,kb
691  WRITE(ipt,80) k,z(1,k),zz(1,k),dz(1,k),dzz(1,k)
692  END DO
693  CASE(stype_geometric)
694  DO k=1,kb
695  WRITE(ipt,80) k,z(1,k),zz(1,k),dz(1,k),dzz(1,k)
696  END DO
697  CASE(stype_tanh)
698  DO k=1,kb
699  WRITE(ipt,80) k,z(1,k),zz(1,k),dz(1,k),dzz(1,k)
700  END DO
701  CASE(stype_generalized) ! THIS IS CASE SPECIFIC
702  WRITE(ipt,*)"SET CASE SPECIFIC GENERALIZED SIGMA LAYER OUTPUT TO SCREEN &
703  &IN mod_setup.F"
704  END SELECT
705  WRITE(ipt,* )'!'
706  END IF
707 
708  IF(dbg_set(dbg_sbr)) WRITE(ipt,*)"END SETUP_SIGMA_DERIVATIVES"
709 
710  !----------FORMAT STATEMENTS---------------------------------------------------!
711 
712 70 FORMAT(2x,'k',13x,'z',11x,'zz',11x,'dz',11x,'dzz')
713 80 FORMAT(' ',i5,4f13.8)
714 
715 
716  IF(dbg_set(dbg_sbr)) WRITE(ipt,*)"SETUP_SIGMA_DERIVATIVES: END"
717  END SUBROUTINE setup_sigma_derivatives
718 
719 END MODULE mod_setup
720 
subroutine coordinate_units(XL, YL)
Definition: mod_setup.f90:300
real(sp) vymax
Definition: mod_main.f90:989
real(sp), dimension(:), allocatable, target cor
Definition: mod_main.f90:1113
real(sp), dimension(:), allocatable, target x_gbl
Definition: mod_setup.f90:54
real(sp), dimension(:), allocatable, target h
Definition: mod_main.f90:1131
subroutine setup_center_coords
Definition: mod_setup.f90:74
logical function dbg_set(vrb)
Definition: mod_utils.f90:182
subroutine load_horizontal_mixing_coefficient(NN, CC)
Definition: mod_input.f90:1690
real(sp), dimension(:), allocatable, target h_lcl
Definition: mod_setup.f90:61
integer nsponge
Definition: mod_setup.f90:66
real(sp), dimension(:), allocatable, target yc
Definition: mod_main.f90:1004
real(sp), dimension(:), allocatable cc_hvc
Definition: mod_main.f90:1302
real(sp), dimension(:), allocatable, target x_lcl
Definition: mod_setup.f90:55
real(sp), dimension(:), allocatable, target ymc
Definition: mod_main.f90:994
real(sp), dimension(:), allocatable, target c_spg
Definition: mod_setup.f90:65
real(sp), dimension(:,:), allocatable, target dzz1
Definition: mod_main.f90:1097
real(sp), dimension(:), allocatable, target latc
Definition: mod_main.f90:998
real(sp), dimension(:), allocatable, target r_spg
Definition: mod_setup.f90:65
real(sp), dimension(:), allocatable, target y_spg
Definition: mod_setup.f90:65
real(sp) vymin
Definition: mod_main.f90:989
subroutine setup_bottom_roughness
Definition: mod_setup.f90:166
real(sp), dimension(:), allocatable, target vx
Definition: mod_main.f90:1001
real(sp), dimension(:), allocatable, target grav_e
Definition: mod_main.f90:1013
subroutine setup_coriolis
Definition: mod_setup.f90:214
real(sp), dimension(:), allocatable nn_hvc
Definition: mod_main.f90:1303
real(sp), dimension(:), allocatable, target vy
Definition: mod_main.f90:1002
real(sp), dimension(:), allocatable, target xmc
Definition: mod_main.f90:993
subroutine setup_sponge
Definition: mod_setup.f90:257
real(sp), dimension(:), allocatable, target lonc
Definition: mod_main.f90:997
integer, parameter dbg_sbrio
Definition: mod_utils.f90:70
real(sp), dimension(:), allocatable, target cc_z0b
Definition: mod_main.f90:1171
real(sp), dimension(:), allocatable, target x_spg
Definition: mod_setup.f90:65
integer, dimension(:,:), allocatable, target nv
Definition: mod_main.f90:1018
real(sp), dimension(:), allocatable, target c_lcl
Definition: mod_setup.f90:58
integer, dimension(:), allocatable, target n_spg
Definition: mod_setup.f90:64
real(sp), dimension(:), allocatable, target xm
Definition: mod_main.f90:991
subroutine setup_depth
Definition: mod_setup.f90:195
real(sp), dimension(:), allocatable, target y_lcl
Definition: mod_setup.f90:55
real(sp), dimension(:,:), allocatable, target zz1
Definition: mod_main.f90:1095
real(sp), dimension(:,:), allocatable, target dzz
Definition: mod_main.f90:1093
subroutine n2e2d(NVAR, EVAR)
Definition: mod_main.f90:1390
real(sp), dimension(:,:), allocatable, target dz
Definition: mod_main.f90:1092
subroutine setup_gravity
Definition: mod_setup.f90:241
real(sp), dimension(:), allocatable, target lat
Definition: mod_main.f90:996
real(sp), dimension(:,:), allocatable, target z
Definition: mod_main.f90:1090
real(sp) vxmax
Definition: mod_main.f90:989
subroutine load_bottom_roughness(Z0)
Definition: mod_input.f90:1747
subroutine fatal_error(ER1, ER2, ER3, ER4)
Definition: mod_utils.f90:230
real(sp), dimension(:), allocatable, target lon
Definition: mod_main.f90:995
real(sp), dimension(:), allocatable, target xc
Definition: mod_main.f90:1003
real(sp), dimension(:), allocatable, target y_gbl
Definition: mod_setup.f90:54
real(sp), dimension(:,:), allocatable, target dz1
Definition: mod_main.f90:1096
real(sp), dimension(:,:), allocatable, target z1
Definition: mod_main.f90:1094
real(sp), dimension(:), allocatable, target grav_n
Definition: mod_main.f90:1013
real(sp), dimension(:), allocatable, target cc_sponge
Definition: mod_main.f90:1127
integer, parameter dbg_sbr
Definition: mod_utils.f90:69
subroutine setup_sigma
Definition: mod_setup.f90:403
real(sp), dimension(:,:), allocatable, target zz
Definition: mod_main.f90:1091
subroutine setup_horizontal_mixing_coefficient
Definition: mod_setup.f90:134
subroutine setup_sigma_derivatives
Definition: mod_setup.f90:636
integer, parameter dbg_log
Definition: mod_utils.f90:65
real(sp), dimension(:), allocatable, target ym
Definition: mod_main.f90:992
real(sp) vxmin
Definition: mod_main.f90:989