My Project
phy_baropg.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 !==============================================================================|
41 ! This subroutine is used to calculate the baroclinic pressure !
42 ! gradient in the standarded z-levels. The water column is divided !
43 ! into 600 standard levels, and pressure gradient is then determined !
44 ! at each level. The resulting pressure gradients are converted back !
45 ! to sigma-levels through vertical interpolation approach. !
46 !==============================================================================|
47 
48  SUBROUTINE phy_baropg
49 
50 !------------------------------------------------------------------------------|
51 
52  USE all_vars
53  USE sinter
54  IMPLICIT NONE
55  INTEGER, PARAMETER :: KBB=601
56  INTEGER, PARAMETER :: KBBM1=kbb-1
57  REAL(SP) RHOZ(M,KBBM1),RHOZTMP(KBBM1),PHY_Z(KBBM1)
58  REAL(SP) RHOS(KBM1),SIGZTMP(KBM1),SIG_Z(M,KBM1)
59  REAL(SP) PB1(0:KBBM1),PB2(0:KBBM1),PB3(0:KBBM1)
60  REAL(SP) PBXZ(KBBM1),PBYZ(KBBM1)
61  REAL(SP) PBXS(KBM1) ,PBYS(KBM1)
62  REAL(SP) AREAX1,AREAX2,AREAX3,AREAY1,AREAY2,AREAY3
63  REAL(SP) RHOZI1,RHOZI2,RHOZI3,TMP,TEMP,DELTZ
64  REAL(SP) GRAV1,GRAV2,GRAV3
65  INTEGER I,K,J1,J2,J3,NTMP
66 
67  ! USE RAMP CALCULATED IN 'internal_step.F'
68 
69 !--CALCULATE Z-LEVELS TO MAX DEPTH---------------------------------------------|
70 
71  deltz=hmax/float(kbbm1)
72 
73  DO k=1,kbbm1
74  phy_z(k)=(0.5_sp-float(k))*deltz
75  END DO
76 
77 !--LINEARLY INTERPOLATE TO OBTAIN DENSITY VALUES AT Z LEVELS-------------------|
78 
79  DO i=1,m
80  DO k=1,kbm1
81  sig_z(i,k)=zz(i,k)*dt(i)+et(i)
82  sigztmp(k)=sig_z(i,k)
83  rhos(k)=rho1(i,k)
84  END DO
85 
86  CALL sinter_extrp_down(sigztmp,rhos,phy_z,rhoztmp,kbm1,kbbm1)
87 
88  DO k=1,kbbm1
89  rhoz(i,k)=rhoztmp(k)
90  END DO
91  END DO
92 
93  DO i=1,n
94  j1=nv(i,1)
95  j2=nv(i,2)
96  j3=nv(i,3)
97  ntmp=0
98  pb1(0)=0.0_sp
99  pb2(0)=0.0_sp
100  pb3(0)=0.0_sp
101  DO k=1,kbbm1
102  tmp=float(k)*deltz
103  IF((h(j1) < tmp.OR.h(j2) < tmp.OR.h(j3) < tmp)) THEN
104  pb1(k)=0.0_sp
105  pb2(k)=0.0_sp
106  pb3(k)=0.0_sp
107  ELSE
108  rhozi1=0.5_sp*(rhoz(j2,k)+rhoz(j3,k))
109  rhozi2=0.5_sp*(rhoz(j3,k)+rhoz(j1,k))
110  rhozi3=0.5_sp*(rhoz(j1,k)+rhoz(j2,k))
111  grav1 =0.5_sp*(grav_n(j2)+grav_n(j3))
112  grav2 =0.5_sp*(grav_n(j3)+grav_n(j1))
113  grav3 =0.5_sp*(grav_n(j1)+grav_n(j2))
114  pb1(k)=pb1(k-1)+grav1*rhozi1*deltz
115  pb2(k)=pb2(k-1)+grav2*rhozi2*deltz
116  pb3(k)=pb3(k-1)+grav3*rhozi3*deltz
117  ntmp=ntmp+1
118  END IF
119  END DO
120  areax1=(vy(j3)-vy(j2))*deltz
121  areay1=(vx(j2)-vx(j3))*deltz
122  areax2=(vy(j1)-vy(j3))*deltz
123  areay2=(vx(j3)-vx(j1))*deltz
124  areax3=(vy(j2)-vy(j1))*deltz
125  areay3=(vx(j1)-vx(j2))*deltz
126  DO k=1,kbbm1
127  pbxz(k)=areax1*pb1(k)+areax2*pb2(k)+areax3*pb3(k)
128  pbyz(k)=areay1*pb1(k)+areay2*pb2(k)+areay3*pb3(k)
129  pbxz(k)=pbxz(k)/art(i)/deltz
130  pbyz(k)=pbyz(k)/art(i)/deltz
131  END DO
132 
133  DO k=1,kbm1
134  j1=nv(i,1)
135  j2=nv(i,2)
136  j3=nv(i,3)
137  sigztmp(k)=(sig_z(j1,k)+sig_z(j2,k)+sig_z(j3,k))/3.
138  END DO
139 
140  IF(ntmp == 0) THEN
141  DO k=1,kbm1
142  pbxs(k)=0.0_sp
143  pbys(k)=0.0_sp
144  END DO
145  ELSE IF(ntmp == 1) THEN
146  DO k=1,kbm1
147  pbxs(k)=pbxz(1)
148  pbys(k)=pbyz(1)
149  END DO
150  ELSE
151  CALL sinter_extrp_down(phy_z,pbxz,sigztmp,pbxs,ntmp,kbm1)
152  CALL sinter_extrp_down(phy_z,pbyz,sigztmp,pbys,ntmp,kbm1)
153  END IF
154 
155  DO k=1,kbm1
156  drhox(i,k)=-pbxs(k)*dt1(i)*dz1(i,k)*art(i)*ramp
157  drhoy(i,k)=-pbys(k)*dt1(i)*dz1(i,k)*art(i)*ramp
158  END DO
159  END DO
160 
161  RETURN
162  END SUBROUTINE phy_baropg
163 !==============================================================================|
real(sp), dimension(:), allocatable, target h
Definition: mod_main.f90:1131
real(sp), dimension(:), allocatable, target art
Definition: mod_main.f90:1009
real(sp), dimension(:,:), allocatable, target rho1
Definition: mod_main.f90:1309
subroutine sinter_extrp_down(X, A, Y, B, M1, N1)
Definition: sinter.f90:98
real(sp), dimension(:,:), allocatable, target drhox
Definition: mod_main.f90:1326
real(sp), dimension(:), allocatable, target et
Definition: mod_main.f90:1135
real(sp), dimension(:), allocatable, target vx
Definition: mod_main.f90:1001
real(sp), dimension(:), allocatable, target vy
Definition: mod_main.f90:1002
integer, dimension(:,:), allocatable, target nv
Definition: mod_main.f90:1018
real(sp), dimension(:,:), allocatable, target drhoy
Definition: mod_main.f90:1327
subroutine phy_baropg
Definition: phy_baropg.f90:49
real(sp), dimension(:), allocatable, target dt1
Definition: mod_main.f90:1117
real(sp), dimension(:,:), allocatable, target dz1
Definition: mod_main.f90:1096
real(sp), dimension(:), allocatable, target grav_n
Definition: mod_main.f90:1013
real(sp), dimension(:,:), allocatable, target zz
Definition: mod_main.f90:1091
real(sp), dimension(:), allocatable, target dt
Definition: mod_main.f90:1133