Skip to content
This repository was archived by the owner on Apr 18, 2018. It is now read-only.

Commit f6bb025

Browse files
authored
Merge pull request #10 from dfer22/bugfix_thebug
Code for MSE coordinate (first try with Github!)
2 parents 3789d22 + ce14b43 commit f6bb025

File tree

4 files changed

+59
-9
lines changed

4 files changed

+59
-9
lines changed

doc/tag-index

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Notes on tags used in MITgcmUV
22
==============================
33

4+
o Add moist-static energy mode (MSE_LAYERS) to package layers.
45
o migrate from CVS to Git
56
o pkg/cheapaml: major changes to relaxation coefficient setting:
67
- rename parameters cheapaml_taurelax & cheapaml_taurelaxocean (in days)

pkg/layers/LAYERS_OPTIONS.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,8 @@ C The MNC stuff is too complicated
2626
C Allow use of potential density as a layering field.
2727
#define LAYERS_PRHO_REF
2828

29+
C Allow use of Moist Static Energy as a coordinate (relevant in the atmosphere)
30+
#undef MSE_LAYERS
31+
2932
#endif /* ALLOW_LAYERS */
3033
#endif /* LAYERS_OPTIONS_H */

pkg/layers/layers_calc.F

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ SUBROUTINE LAYERS_CALC(
2929
#ifdef ALLOW_GMREDI
3030
# include "GMREDI.h"
3131
#endif
32-
32+
#ifdef LAYERS_PRHO_REF
33+
# include "EOS.h"
34+
#endif
3335
C !INPUT PARAMETERS:
3436
C myTime :: Current time in simulation
3537
C myIter :: Current iteration number
@@ -71,9 +73,9 @@ SUBROUTINE LAYERS_CALC(
7173
_RL layers_V (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nlayers,nSx,nSy)
7274
# endif /* LAYERS_THICKNESS */
7375
#endif /* LAYERS_VFLUX */
74-
#ifdef LAYERS_PRHO_REF
76+
#if (defined LAYERS_PRHO_REF) || (defined MSE_LAYERS)
7577
_RL prho(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy)
76-
_RL rhoShift
78+
_RL rhoShift, conv_theta2T
7779
INTEGER i, j, k
7880
#endif
7981
C -- other local variables:
@@ -174,12 +176,21 @@ SUBROUTINE LAYERS_CALC(
174176
ENDDO
175177
ENDDO
176178
DO k = 1,Nr
177-
CALL FIND_RHO_2D( 1-OLx, sNx+OLx, 1-OLy, sNy+OLy,
178-
& layers_krho(iLa),
179-
& theta(1-OLx,1-OLy,k,bi,bj),
180-
& salt(1-OLx,1-OLy,k,bi,bj),
181-
& prho(1-OLx,1-OLy,k,bi,bj),
182-
& k, bi, bj, myThid )
179+
IF (equationOfState.EQ.'LINEAR') THEN
180+
CALL FIND_RHO_2D( 1-OLx, sNx+OLx, 1-OLy, sNy+OLy,
181+
& k,
182+
& theta(1-OLx,1-OLy,k,bi,bj),
183+
& salt(1-OLx,1-OLy,k,bi,bj),
184+
& prho(1-OLx,1-OLy,k,bi,bj),
185+
& k, bi, bj, myThid )
186+
ELSE
187+
CALL FIND_RHO_2D( 1-OLx, sNx+OLx, 1-OLy, sNy+OLy,
188+
& layers_krho(iLa),
189+
& theta(1-OLx,1-OLy,k,bi,bj),
190+
& salt(1-OLx,1-OLy,k,bi,bj),
191+
& prho(1-OLx,1-OLy,k,bi,bj),
192+
& k, bi, bj, myThid )
193+
ENDIF
183194
#ifdef LAYERS_THERMODYNAMICS
184195
C -- it might be more memory efficient not to store alpha and beta
185196
C but to multiply the fluxes in place here
@@ -218,6 +229,30 @@ SUBROUTINE LAYERS_CALC(
218229
& myThid)
219230
#endif
220231
#endif /* LAYERS_PRHO_REF */
232+
ELSEIF ( layers_num(iLa) .EQ. 4 ) THEN
233+
#ifdef MSE_LAYERS
234+
C For layers_num(iLa) = 4, calculate the absolute temperature referenced to 1000 mb
235+
DO bj=myByLo(myThid),myByHi(myThid)
236+
DO bi=myBxLo(myThid),myBxHi(myThid)
237+
DO k = 1,Nr
238+
conv_theta2T = (rC(k)/atm_Po)**atm_kappa
239+
DO j = 1-OLy,sNy+OLy
240+
DO i = 1-OLx,sNx+OLx
241+
prho(i,j,k,bi,bj) = atm_Cp*conv_theta2T*theta(i,j,k,bi,bj)
242+
& + totPhiHyd(i,j,k,bi,bj) + phiRef(2*k)
243+
& + 2501. _d 0 * salt(i,j,k,bi,bj)
244+
ENDDO
245+
ENDDO
246+
ENDDO
247+
ENDDO
248+
ENDDO
249+
CALL LAYERS_FLUXCALC( uVel,vVel, prho, iLa,
250+
& layers_UH, layers_VH,
251+
& layers_Hw, layers_Hs,
252+
& layers_PIw,layers_PIs,
253+
& layers_U, layers_V,
254+
& myThid )
255+
#endif /* MSE_LAYERS */
221256
ENDIF
222257

223258
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|

pkg/layers/layers_readparms.F

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ SUBROUTINE LAYERS_READPARMS( myThid )
147147
IF ( layers_name(iLa).EQ.'TH ' ) layers_num(iLa) = 1
148148
IF ( layers_name(iLa).EQ.'SLT' ) layers_num(iLa) = 2
149149
IF ( layers_name(iLa).EQ.'RHO' ) layers_num(iLa) = 3
150+
IF ( layers_name(iLa).EQ.'MSE' ) layers_num(iLa) = 4
150151
IF ( layers_name(iLa).NE.' ' .AND.
151152
& layers_num(iLa).EQ.0 ) THEN
152153
WRITE(msgBuf,'(2A,I2,3A)') 'LAYERS_READPARMS: ',
@@ -172,6 +173,16 @@ SUBROUTINE LAYERS_READPARMS( myThid )
172173
ENDIF
173174
ENDDO
174175

176+
#ifndef LAYERS_PRHO_REF
177+
IF ( LAYER_nb .EQ. 3 ) THEN
178+
WRITE(msgBuf,'(2A,I4)')
179+
& 'S/R LAYERS_READPARMS: ',
180+
& 'Layering in density requires to define LAYERS_PRHO_REF'
181+
CALL PRINT_ERROR( msgBuf, myThid )
182+
STOP 'ABNORMAL END: S/R LAYERS_READPARMS'
183+
ENDIF
184+
#endif
185+
175186
C-- Make sure that we locally honor the global MNC on/off flag
176187
layers_MNC = layers_MNC .AND. useMNC
177188
#ifndef ALLOW_MNC

0 commit comments

Comments
 (0)