12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424 |
- MODULE dynhpg
- !!======================================================================
- !! *** MODULE dynhpg ***
- !! Ocean dynamics: hydrostatic pressure gradient trend
- !!======================================================================
- !! History : OPA ! 1987-09 (P. Andrich, M.-A. Foujols) hpg_zco: Original code
- !! 5.0 ! 1991-11 (G. Madec)
- !! 7.0 ! 1996-01 (G. Madec) hpg_sco: Original code for s-coordinates
- !! 8.0 ! 1997-05 (G. Madec) split dynber into dynkeg and dynhpg
- !! 8.5 ! 2002-07 (G. Madec) F90: Free form and module
- !! 8.5 ! 2002-08 (A. Bozec) hpg_zps: Original code
- !! NEMO 1.0 ! 2005-10 (A. Beckmann, B.W. An) various s-coordinate options
- !! ! Original code for hpg_ctl, hpg_hel hpg_wdj, hpg_djc, hpg_rot
- !! - ! 2005-11 (G. Madec) style & small optimisation
- !! 3.3 ! 2010-10 (C. Ethe, G. Madec) reorganisation of initialisation phase
- !! 3.4 ! 2011-11 (H. Liu) hpg_prj: Original code for s-coordinates
- !! ! (A. Coward) suppression of hel, wdj and rot options
- !! 3.6 ! 2014-11 (P. Mathiot) hpg_isf: original code for ice shelf cavity
- !!----------------------------------------------------------------------
- !!----------------------------------------------------------------------
- !! dyn_hpg : update the momentum trend with the now horizontal
- !! gradient of the hydrostatic pressure
- !! dyn_hpg_init : initialisation and control of options
- !! hpg_zco : z-coordinate scheme
- !! hpg_zps : z-coordinate plus partial steps (interpolation)
- !! hpg_sco : s-coordinate (standard jacobian formulation)
- !! hpg_isf : s-coordinate (sco formulation) adapted to ice shelf
- !! hpg_djc : s-coordinate (Density Jacobian with Cubic polynomial)
- !! hpg_prj : s-coordinate (Pressure Jacobian with Cubic polynomial)
- !!----------------------------------------------------------------------
- USE oce ! ocean dynamics and tracers
- USE sbc_oce ! surface variable (only for the flag with ice shelf)
- USE dom_oce ! ocean space and time domain
- USE phycst ! physical constants
- USE trd_oce ! trends: ocean variables
- USE trddyn ! trend manager: dynamics
- !
- USE in_out_manager ! I/O manager
- USE prtctl ! Print control
- USE lbclnk ! lateral boundary condition
- USE lib_mpp ! MPP library
- USE eosbn2 ! compute density
- USE wrk_nemo ! Memory Allocation
- USE timing ! Timing
- IMPLICIT NONE
- PRIVATE
- PUBLIC dyn_hpg ! routine called by step module
- PUBLIC dyn_hpg_init ! routine called by opa module
- ! !!* Namelist namdyn_hpg : hydrostatic pressure gradient
- LOGICAL , PUBLIC :: ln_hpg_zco !: z-coordinate - full steps
- LOGICAL , PUBLIC :: ln_hpg_zps !: z-coordinate - partial steps (interpolation)
- LOGICAL , PUBLIC :: ln_hpg_sco !: s-coordinate (standard jacobian formulation)
- LOGICAL , PUBLIC :: ln_hpg_djc !: s-coordinate (Density Jacobian with Cubic polynomial)
- LOGICAL , PUBLIC :: ln_hpg_prj !: s-coordinate (Pressure Jacobian scheme)
- LOGICAL , PUBLIC :: ln_hpg_isf !: s-coordinate similar to sco modify for isf
- LOGICAL , PUBLIC :: ln_dynhpg_imp !: semi-implicite hpg flag
- INTEGER , PUBLIC :: nhpg = 0 ! = 0 to 7, type of pressure gradient scheme used ! (deduced from ln_hpg_... flags) (PUBLIC for TAM)
- !! * Substitutions
- # include "domzgr_substitute.h90"
- # include "vectopt_loop_substitute.h90"
- !!----------------------------------------------------------------------
- !! NEMO/OPA 3.3 , NEMO Consortium (2010)
- !! $Id: dynhpg.F90 4990 2014-12-15 16:42:49Z timgraham $
- !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
- !!----------------------------------------------------------------------
- CONTAINS
- SUBROUTINE dyn_hpg( kt )
- !!---------------------------------------------------------------------
- !! *** ROUTINE dyn_hpg ***
- !!
- !! ** Method : Call the hydrostatic pressure gradient routine
- !! using the scheme defined in the namelist
- !!
- !! ** Action : - Update (ua,va) with the now hydrastatic pressure trend
- !! - send trends to trd_dyn for futher diagnostics (l_trddyn=T)
- !!----------------------------------------------------------------------
- INTEGER, INTENT(in) :: kt ! ocean time-step index
- REAL(wp), POINTER, DIMENSION(:,:,:) :: ztrdu, ztrdv
- !!----------------------------------------------------------------------
- !
- IF( nn_timing == 1 ) CALL timing_start('dyn_hpg')
- !
- IF( l_trddyn ) THEN ! Temporary saving of ua and va trends (l_trddyn)
- CALL wrk_alloc( jpi,jpj,jpk, ztrdu, ztrdv )
- ztrdu(:,:,:) = ua(:,:,:)
- ztrdv(:,:,:) = va(:,:,:)
- ENDIF
- !
- SELECT CASE ( nhpg ) ! Hydrostatic pressure gradient computation
- CASE ( 0 ) ; CALL hpg_zco ( kt ) ! z-coordinate
- CASE ( 1 ) ; CALL hpg_zps ( kt ) ! z-coordinate plus partial steps (interpolation)
- CASE ( 2 ) ; CALL hpg_sco ( kt ) ! s-coordinate (standard jacobian formulation)
- CASE ( 3 ) ; CALL hpg_djc ( kt ) ! s-coordinate (Density Jacobian with Cubic polynomial)
- CASE ( 4 ) ; CALL hpg_prj ( kt ) ! s-coordinate (Pressure Jacobian scheme)
- CASE ( 5 ) ; CALL hpg_isf ( kt ) ! s-coordinate similar to sco modify for ice shelf
- END SELECT
- !
- IF( l_trddyn ) THEN ! save the hydrostatic pressure gradient trends for momentum trend diagnostics
- ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
- ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
- CALL trd_dyn( ztrdu, ztrdv, jpdyn_hpg, kt )
- CALL wrk_dealloc( jpi,jpj,jpk, ztrdu, ztrdv )
- ENDIF
- !
- IF(ln_ctl) CALL prt_ctl( tab3d_1=ua, clinfo1=' hpg - Ua: ', mask1=umask, &
- & tab3d_2=va, clinfo2= ' Va: ', mask2=vmask, clinfo3='dyn' )
- !
- IF( nn_timing == 1 ) CALL timing_stop('dyn_hpg')
- !
- END SUBROUTINE dyn_hpg
- SUBROUTINE dyn_hpg_init
- !!----------------------------------------------------------------------
- !! *** ROUTINE dyn_hpg_init ***
- !!
- !! ** Purpose : initializations for the hydrostatic pressure gradient
- !! computation and consistency control
- !!
- !! ** Action : Read the namelist namdyn_hpg and check the consistency
- !! with the type of vertical coordinate used (zco, zps, sco)
- !!----------------------------------------------------------------------
- INTEGER :: ioptio = 0 ! temporary integer
- INTEGER :: ios ! Local integer output status for namelist read
- !!
- NAMELIST/namdyn_hpg/ ln_hpg_zco, ln_hpg_zps, ln_hpg_sco, &
- & ln_hpg_djc, ln_hpg_prj, ln_hpg_isf, ln_dynhpg_imp
- !!----------------------------------------------------------------------
- !
- REWIND( numnam_ref ) ! Namelist namdyn_hpg in reference namelist : Hydrostatic pressure gradient
- READ ( numnam_ref, namdyn_hpg, IOSTAT = ios, ERR = 901)
- 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namdyn_hpg in reference namelist', lwp )
- REWIND( numnam_cfg ) ! Namelist namdyn_hpg in configuration namelist : Hydrostatic pressure gradient
- READ ( numnam_cfg, namdyn_hpg, IOSTAT = ios, ERR = 902 )
- 902 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namdyn_hpg in configuration namelist', lwp )
- IF(lwm) WRITE ( numond, namdyn_hpg )
- !
- IF(lwp) THEN ! Control print
- WRITE(numout,*)
- WRITE(numout,*) 'dyn_hpg_init : hydrostatic pressure gradient initialisation'
- WRITE(numout,*) '~~~~~~~~~~~~'
- WRITE(numout,*) ' Namelist namdyn_hpg : choice of hpg scheme'
- WRITE(numout,*) ' z-coord. - full steps ln_hpg_zco = ', ln_hpg_zco
- WRITE(numout,*) ' z-coord. - partial steps (interpolation) ln_hpg_zps = ', ln_hpg_zps
- WRITE(numout,*) ' s-coord. (standard jacobian formulation) ln_hpg_sco = ', ln_hpg_sco
- WRITE(numout,*) ' s-coord. (standard jacobian formulation) for isf ln_hpg_isf = ', ln_hpg_isf
- WRITE(numout,*) ' s-coord. (Density Jacobian: Cubic polynomial) ln_hpg_djc = ', ln_hpg_djc
- WRITE(numout,*) ' s-coord. (Pressure Jacobian: Cubic polynomial) ln_hpg_prj = ', ln_hpg_prj
- WRITE(numout,*) ' time stepping: centered (F) or semi-implicit (T) ln_dynhpg_imp = ', ln_dynhpg_imp
- ENDIF
- !
- IF( ln_hpg_djc ) &
- & CALL ctl_stop('dyn_hpg_init : Density Jacobian: Cubic polynominal method &
- & currently disabled (bugs under investigation). Please select &
- & either ln_hpg_sco or ln_hpg_prj instead')
- !
- IF( lk_vvl .AND. .NOT. (ln_hpg_sco.OR.ln_hpg_prj.OR.ln_hpg_isf) ) &
- & CALL ctl_stop('dyn_hpg_init : variable volume key_vvl requires:&
- & the standard jacobian formulation hpg_sco or &
- & the pressure jacobian formulation hpg_prj')
- IF( ln_hpg_isf .AND. .NOT. ln_isfcav ) &
- & CALL ctl_stop( ' hpg_isf not available if ln_isfcav = false ' )
- IF( .NOT. ln_hpg_isf .AND. ln_isfcav ) &
- & CALL ctl_stop( 'Only hpg_isf has been corrected to work with ice shelf cavity.' )
- !
- ! ! Set nhpg from ln_hpg_... flags
- IF( ln_hpg_zco ) nhpg = 0
- IF( ln_hpg_zps ) nhpg = 1
- IF( ln_hpg_sco ) nhpg = 2
- IF( ln_hpg_djc ) nhpg = 3
- IF( ln_hpg_prj ) nhpg = 4
- IF( ln_hpg_isf ) nhpg = 5
- !
- ! ! Consistency check
- ioptio = 0
- IF( ln_hpg_zco ) ioptio = ioptio + 1
- IF( ln_hpg_zps ) ioptio = ioptio + 1
- IF( ln_hpg_sco ) ioptio = ioptio + 1
- IF( ln_hpg_djc ) ioptio = ioptio + 1
- IF( ln_hpg_prj ) ioptio = ioptio + 1
- IF( ln_hpg_isf ) ioptio = ioptio + 1
- IF( ioptio /= 1 ) CALL ctl_stop( 'NO or several hydrostatic pressure gradient options used' )
- !
- ! initialisation of ice load
- riceload(:,:)=0.0
- !
- END SUBROUTINE dyn_hpg_init
- SUBROUTINE hpg_zco( kt )
- !!---------------------------------------------------------------------
- !! *** ROUTINE hpg_zco ***
- !!
- !! ** Method : z-coordinate case, levels are horizontal surfaces.
- !! The now hydrostatic pressure gradient at a given level, jk,
- !! is computed by taking the vertical integral of the in-situ
- !! density gradient along the model level from the suface to that
- !! level: zhpi = grav .....
- !! zhpj = grav .....
- !! add it to the general momentum trend (ua,va).
- !! ua = ua - 1/e1u * zhpi
- !! va = va - 1/e2v * zhpj
- !!
- !! ** Action : - Update (ua,va) with the now hydrastatic pressure trend
- !!----------------------------------------------------------------------
- INTEGER, INTENT(in) :: kt ! ocean time-step index
- !!
- INTEGER :: ji, jj, jk ! dummy loop indices
- REAL(wp) :: zcoef0, zcoef1 ! temporary scalars
- REAL(wp), POINTER, DIMENSION(:,:,:) :: zhpi, zhpj
- !!----------------------------------------------------------------------
- !
- CALL wrk_alloc( jpi,jpj,jpk, zhpi, zhpj )
- !
- IF( kt == nit000 ) THEN
- IF(lwp) WRITE(numout,*)
- IF(lwp) WRITE(numout,*) 'dyn:hpg_zco : hydrostatic pressure gradient trend'
- IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ z-coordinate case '
- ENDIF
- zcoef0 = - grav * 0.5_wp ! Local constant initialization
- ! Surface value
- DO jj = 2, jpjm1
- DO ji = fs_2, fs_jpim1 ! vector opt.
- zcoef1 = zcoef0 * fse3w(ji,jj,1)
- ! hydrostatic pressure gradient
- zhpi(ji,jj,1) = zcoef1 * ( rhd(ji+1,jj,1) - rhd(ji,jj,1) ) / e1u(ji,jj)
- zhpj(ji,jj,1) = zcoef1 * ( rhd(ji,jj+1,1) - rhd(ji,jj,1) ) / e2v(ji,jj)
- ! add to the general momentum trend
- ua(ji,jj,1) = ua(ji,jj,1) + zhpi(ji,jj,1)
- va(ji,jj,1) = va(ji,jj,1) + zhpj(ji,jj,1)
- END DO
- END DO
- !
- ! interior value (2=<jk=<jpkm1)
- DO jk = 2, jpkm1
- DO jj = 2, jpjm1
- DO ji = fs_2, fs_jpim1 ! vector opt.
- zcoef1 = zcoef0 * fse3w(ji,jj,jk)
- ! hydrostatic pressure gradient
- zhpi(ji,jj,jk) = zhpi(ji,jj,jk-1) &
- & + zcoef1 * ( ( rhd(ji+1,jj,jk)+rhd(ji+1,jj,jk-1) ) &
- & - ( rhd(ji ,jj,jk)+rhd(ji ,jj,jk-1) ) ) / e1u(ji,jj)
- zhpj(ji,jj,jk) = zhpj(ji,jj,jk-1) &
- & + zcoef1 * ( ( rhd(ji,jj+1,jk)+rhd(ji,jj+1,jk-1) ) &
- & - ( rhd(ji,jj, jk)+rhd(ji,jj ,jk-1) ) ) / e2v(ji,jj)
- ! add to the general momentum trend
- ua(ji,jj,jk) = ua(ji,jj,jk) + zhpi(ji,jj,jk)
- va(ji,jj,jk) = va(ji,jj,jk) + zhpj(ji,jj,jk)
- END DO
- END DO
- END DO
- !
- CALL wrk_dealloc( jpi,jpj,jpk, zhpi, zhpj )
- !
- END SUBROUTINE hpg_zco
- SUBROUTINE hpg_zps( kt )
- !!---------------------------------------------------------------------
- !! *** ROUTINE hpg_zps ***
- !!
- !! ** Method : z-coordinate plus partial steps case. blahblah...
- !!
- !! ** Action : - Update (ua,va) with the now hydrastatic pressure trend
- !!----------------------------------------------------------------------
- INTEGER, INTENT(in) :: kt ! ocean time-step index
- !!
- INTEGER :: ji, jj, jk ! dummy loop indices
- INTEGER :: iku, ikv ! temporary integers
- REAL(wp) :: zcoef0, zcoef1, zcoef2, zcoef3 ! temporary scalars
- REAL(wp), POINTER, DIMENSION(:,:,:) :: zhpi, zhpj
- !!----------------------------------------------------------------------
- !
- CALL wrk_alloc( jpi,jpj,jpk, zhpi, zhpj )
- !
- IF( kt == nit000 ) THEN
- IF(lwp) WRITE(numout,*)
- IF(lwp) WRITE(numout,*) 'dyn:hpg_zps : hydrostatic pressure gradient trend'
- IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ z-coordinate with partial steps - vector optimization'
- ENDIF
- ! Local constant initialization
- zcoef0 = - grav * 0.5_wp
- ! Surface value (also valid in partial step case)
- DO jj = 2, jpjm1
- DO ji = fs_2, fs_jpim1 ! vector opt.
- zcoef1 = zcoef0 * fse3w(ji,jj,1)
- ! hydrostatic pressure gradient
- zhpi(ji,jj,1) = zcoef1 * ( rhd(ji+1,jj ,1) - rhd(ji,jj,1) ) / e1u(ji,jj)
- zhpj(ji,jj,1) = zcoef1 * ( rhd(ji ,jj+1,1) - rhd(ji,jj,1) ) / e2v(ji,jj)
- ! add to the general momentum trend
- ua(ji,jj,1) = ua(ji,jj,1) + zhpi(ji,jj,1)
- va(ji,jj,1) = va(ji,jj,1) + zhpj(ji,jj,1)
- END DO
- END DO
- ! interior value (2=<jk=<jpkm1)
- DO jk = 2, jpkm1
- DO jj = 2, jpjm1
- DO ji = fs_2, fs_jpim1 ! vector opt.
- zcoef1 = zcoef0 * fse3w(ji,jj,jk)
- ! hydrostatic pressure gradient
- zhpi(ji,jj,jk) = zhpi(ji,jj,jk-1) &
- & + zcoef1 * ( ( rhd(ji+1,jj,jk) + rhd(ji+1,jj,jk-1) ) &
- & - ( rhd(ji ,jj,jk) + rhd(ji ,jj,jk-1) ) ) / e1u(ji,jj)
- zhpj(ji,jj,jk) = zhpj(ji,jj,jk-1) &
- & + zcoef1 * ( ( rhd(ji,jj+1,jk) + rhd(ji,jj+1,jk-1) ) &
- & - ( rhd(ji,jj, jk) + rhd(ji,jj ,jk-1) ) ) / e2v(ji,jj)
- ! add to the general momentum trend
- ua(ji,jj,jk) = ua(ji,jj,jk) + zhpi(ji,jj,jk)
- va(ji,jj,jk) = va(ji,jj,jk) + zhpj(ji,jj,jk)
- END DO
- END DO
- END DO
- ! partial steps correction at the last level (use gru & grv computed in zpshde.F90)
- DO jj = 2, jpjm1
- DO ji = 2, jpim1
- iku = mbku(ji,jj)
- ikv = mbkv(ji,jj)
- zcoef2 = zcoef0 * MIN( fse3w(ji,jj,iku), fse3w(ji+1,jj ,iku) )
- zcoef3 = zcoef0 * MIN( fse3w(ji,jj,ikv), fse3w(ji ,jj+1,ikv) )
- IF( iku > 1 ) THEN ! on i-direction (level 2 or more)
- ua (ji,jj,iku) = ua(ji,jj,iku) - zhpi(ji,jj,iku) ! subtract old value
- zhpi(ji,jj,iku) = zhpi(ji,jj,iku-1) & ! compute the new one
- & + zcoef2 * ( rhd(ji+1,jj,iku-1) - rhd(ji,jj,iku-1) + gru(ji,jj) ) / e1u(ji,jj)
- ua (ji,jj,iku) = ua(ji,jj,iku) + zhpi(ji,jj,iku) ! add the new one to the general momentum trend
- ENDIF
- IF( ikv > 1 ) THEN ! on j-direction (level 2 or more)
- va (ji,jj,ikv) = va(ji,jj,ikv) - zhpj(ji,jj,ikv) ! subtract old value
- zhpj(ji,jj,ikv) = zhpj(ji,jj,ikv-1) & ! compute the new one
- & + zcoef3 * ( rhd(ji,jj+1,ikv-1) - rhd(ji,jj,ikv-1) + grv(ji,jj) ) / e2v(ji,jj)
- va (ji,jj,ikv) = va(ji,jj,ikv) + zhpj(ji,jj,ikv) ! add the new one to the general momentum trend
- ENDIF
- END DO
- END DO
- !
- CALL wrk_dealloc( jpi,jpj,jpk, zhpi, zhpj )
- !
- END SUBROUTINE hpg_zps
- SUBROUTINE hpg_sco( kt )
- !!---------------------------------------------------------------------
- !! *** ROUTINE hpg_sco ***
- !!
- !! ** Method : s-coordinate case. Jacobian scheme.
- !! The now hydrostatic pressure gradient at a given level, jk,
- !! is computed by taking the vertical integral of the in-situ
- !! density gradient along the model level from the suface to that
- !! level. s-coordinates (ln_sco): a corrective term is added
- !! to the horizontal pressure gradient :
- !! zhpi = grav ..... + 1/e1u mi(rhd) di[ grav dep3w ]
- !! zhpj = grav ..... + 1/e2v mj(rhd) dj[ grav dep3w ]
- !! add it to the general momentum trend (ua,va).
- !! ua = ua - 1/e1u * zhpi
- !! va = va - 1/e2v * zhpj
- !!
- !! ** Action : - Update (ua,va) with the now hydrastatic pressure trend
- !!----------------------------------------------------------------------
- INTEGER, INTENT(in) :: kt ! ocean time-step index
- !!
- INTEGER :: ji, jj, jk ! dummy loop indices
- REAL(wp) :: zcoef0, zuap, zvap, znad ! temporary scalars
- REAL(wp), POINTER, DIMENSION(:,:,:) :: zhpi, zhpj
- !!----------------------------------------------------------------------
- !
- CALL wrk_alloc( jpi,jpj,jpk, zhpi, zhpj )
- !
- IF( kt == nit000 ) THEN
- IF(lwp) WRITE(numout,*)
- IF(lwp) WRITE(numout,*) 'dyn:hpg_sco : hydrostatic pressure gradient trend'
- IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ s-coordinate case, OPA original scheme used'
- ENDIF
- ! Local constant initialization
- zcoef0 = - grav * 0.5_wp
- ! To use density and not density anomaly
- IF ( lk_vvl ) THEN ; znad = 1._wp ! Variable volume
- ELSE ; znad = 0._wp ! Fixed volume
- ENDIF
- ! Surface value
- DO jj = 2, jpjm1
- DO ji = fs_2, fs_jpim1 ! vector opt.
- ! hydrostatic pressure gradient along s-surfaces
- zhpi(ji,jj,1) = zcoef0 / e1u(ji,jj) * ( fse3w(ji+1,jj ,1) * ( znad + rhd(ji+1,jj ,1) ) &
- & - fse3w(ji ,jj ,1) * ( znad + rhd(ji ,jj ,1) ) )
- zhpj(ji,jj,1) = zcoef0 / e2v(ji,jj) * ( fse3w(ji ,jj+1,1) * ( znad + rhd(ji ,jj+1,1) ) &
- & - fse3w(ji ,jj ,1) * ( znad + rhd(ji ,jj ,1) ) )
- ! s-coordinate pressure gradient correction
- zuap = -zcoef0 * ( rhd (ji+1,jj,1) + rhd (ji,jj,1) + 2._wp * znad ) &
- & * ( fsde3w(ji+1,jj,1) - fsde3w(ji,jj,1) ) / e1u(ji,jj)
- zvap = -zcoef0 * ( rhd (ji,jj+1,1) + rhd (ji,jj,1) + 2._wp * znad ) &
- & * ( fsde3w(ji,jj+1,1) - fsde3w(ji,jj,1) ) / e2v(ji,jj)
- ! add to the general momentum trend
- ua(ji,jj,1) = ua(ji,jj,1) + zhpi(ji,jj,1) + zuap
- va(ji,jj,1) = va(ji,jj,1) + zhpj(ji,jj,1) + zvap
- END DO
- END DO
- ! interior value (2=<jk=<jpkm1)
- DO jk = 2, jpkm1
- DO jj = 2, jpjm1
- DO ji = fs_2, fs_jpim1 ! vector opt.
- ! hydrostatic pressure gradient along s-surfaces
- zhpi(ji,jj,jk) = zhpi(ji,jj,jk-1) + zcoef0 / e1u(ji,jj) &
- & * ( fse3w(ji+1,jj,jk) * ( rhd(ji+1,jj,jk) + rhd(ji+1,jj,jk-1) + 2*znad ) &
- & - fse3w(ji ,jj,jk) * ( rhd(ji ,jj,jk) + rhd(ji ,jj,jk-1) + 2*znad ) )
- zhpj(ji,jj,jk) = zhpj(ji,jj,jk-1) + zcoef0 / e2v(ji,jj) &
- & * ( fse3w(ji,jj+1,jk) * ( rhd(ji,jj+1,jk) + rhd(ji,jj+1,jk-1) + 2*znad ) &
- & - fse3w(ji,jj ,jk) * ( rhd(ji,jj, jk) + rhd(ji,jj ,jk-1) + 2*znad ) )
- ! s-coordinate pressure gradient correction
- zuap = -zcoef0 * ( rhd (ji+1,jj ,jk) + rhd (ji,jj,jk) + 2._wp * znad ) &
- & * ( fsde3w(ji+1,jj ,jk) - fsde3w(ji,jj,jk) ) / e1u(ji,jj)
- zvap = -zcoef0 * ( rhd (ji ,jj+1,jk) + rhd (ji,jj,jk) + 2._wp * znad ) &
- & * ( fsde3w(ji ,jj+1,jk) - fsde3w(ji,jj,jk) ) / e2v(ji,jj)
- ! add to the general momentum trend
- ua(ji,jj,jk) = ua(ji,jj,jk) + zhpi(ji,jj,jk) + zuap
- va(ji,jj,jk) = va(ji,jj,jk) + zhpj(ji,jj,jk) + zvap
- END DO
- END DO
- END DO
- !
- CALL wrk_dealloc( jpi,jpj,jpk, zhpi, zhpj )
- !
- END SUBROUTINE hpg_sco
- SUBROUTINE hpg_isf( kt )
- !!---------------------------------------------------------------------
- !! *** ROUTINE hpg_sco ***
- !!
- !! ** Method : s-coordinate case. Jacobian scheme.
- !! The now hydrostatic pressure gradient at a given level, jk,
- !! is computed by taking the vertical integral of the in-situ
- !! density gradient along the model level from the suface to that
- !! level. s-coordinates (ln_sco): a corrective term is added
- !! to the horizontal pressure gradient :
- !! zhpi = grav ..... + 1/e1u mi(rhd) di[ grav dep3w ]
- !! zhpj = grav ..... + 1/e2v mj(rhd) dj[ grav dep3w ]
- !! add it to the general momentum trend (ua,va).
- !! ua = ua - 1/e1u * zhpi
- !! va = va - 1/e2v * zhpj
- !! iceload is added and partial cell case are added to the top and bottom
- !!
- !! ** Action : - Update (ua,va) with the now hydrastatic pressure trend
- !!----------------------------------------------------------------------
- INTEGER, INTENT(in) :: kt ! ocean time-step index
- !!
- INTEGER :: ji, jj, jk, iku, ikv, ikt, iktp1i, iktp1j ! dummy loop indices
- REAL(wp) :: zcoef0, zuap, zvap, znad, ze3wu, ze3wv, zuapint, zvapint, zhpjint, zhpiint, zdzwt, zdzwtjp1, zdzwtip1 ! temporary scalars
- REAL(wp), POINTER, DIMENSION(:,:,:) :: zhpi, zhpj, zrhd
- REAL(wp), POINTER, DIMENSION(:,:,:) :: ztstop
- REAL(wp), POINTER, DIMENSION(:,:) :: ze3w, zp, zrhdtop_isf, zrhdtop_oce, ziceload, zdept, zpshpi, zpshpj
- !!----------------------------------------------------------------------
- !
- CALL wrk_alloc( jpi,jpj, 2, ztstop)
- CALL wrk_alloc( jpi,jpj,jpk, zhpi, zhpj, zrhd)
- CALL wrk_alloc( jpi,jpj, ze3w, zp, zrhdtop_isf, zrhdtop_oce, ziceload, zdept, zpshpi, zpshpj)
- !
- IF( kt == nit000 ) THEN
- IF(lwp) WRITE(numout,*)
- IF(lwp) WRITE(numout,*) 'dyn:hpg_isf : hydrostatic pressure gradient trend for ice shelf'
- IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ s-coordinate case, OPA original scheme used'
- ENDIF
- ! Local constant initialization
- zcoef0 = - grav * 0.5_wp
- ! To use density and not density anomaly
- ! IF ( lk_vvl ) THEN ; znad = 1._wp ! Variable volume
- ! ELSE ; znad = 0._wp ! Fixed volume
- ! ENDIF
- znad=1._wp
- ! iniitialised to 0. zhpi zhpi
- zhpi(:,:,:)=0._wp ; zhpj(:,:,:)=0._wp
- !==================================================================================
- !=====Compute iceload and contribution of the half first wet layer =================
- !===================================================================================
- ! assume water displaced by the ice shelf is at T=-1.9 and S=34.4 (rude)
- ztstop(:,:,1)=-1.9_wp ; ztstop(:,:,2)=34.4_wp
- ! compute density of the water displaced by the ice shelf
- zrhd = rhd ! save rhd
- DO jk = 1, jpk
- zdept(:,:)=gdept_1d(jk)
- CALL eos(ztstop(:,:,:),zdept(:,:),rhd(:,:,jk))
- END DO
- WHERE ( tmask(:,:,:) == 1._wp)
- rhd(:,:,:) = zrhd(:,:,:) ! replace wet cell by the saved rhd
- END WHERE
-
- ! compute rhd at the ice/oce interface (ice shelf side)
- CALL eos(ztstop,risfdep,zrhdtop_isf)
- ! compute rhd at the ice/oce interface (ocean side)
- DO ji=1,jpi
- DO jj=1,jpj
- ikt=mikt(ji,jj)
- ztstop(ji,jj,1)=tsn(ji,jj,ikt,1)
- ztstop(ji,jj,2)=tsn(ji,jj,ikt,2)
- END DO
- END DO
- CALL eos(ztstop,risfdep,zrhdtop_oce)
- !
- ! Surface value + ice shelf gradient
- ! compute pressure due to ice shelf load (used to compute hpgi/j for all the level from 1 to miku/v)
- ziceload = 0._wp
- DO jj = 1, jpj
- DO ji = 1, jpi ! vector opt.
- ikt=mikt(ji,jj)
- ziceload(ji,jj) = ziceload(ji,jj) + (znad + rhd(ji,jj,1) ) * fse3w(ji,jj,1) * (1._wp - tmask(ji,jj,1))
- DO jk=2,ikt-1
- ziceload(ji,jj) = ziceload(ji,jj) + (2._wp * znad + rhd(ji,jj,jk-1) + rhd(ji,jj,jk)) * fse3w(ji,jj,jk) &
- & * (1._wp - tmask(ji,jj,jk))
- END DO
- IF (ikt .GE. 2) ziceload(ji,jj) = ziceload(ji,jj) + (2._wp * znad + zrhdtop_isf(ji,jj) + rhd(ji,jj,ikt-1)) &
- & * ( risfdep(ji,jj) - gdept_1d(ikt-1) )
- END DO
- END DO
- riceload(:,:) = 0.0_wp ; riceload(:,:)=ziceload(:,:) ! need to be saved for diaar5
- ! compute zp from z=0 to first T wet point (correction due to zps not yet applied)
- DO jj = 2, jpjm1
- DO ji = fs_2, fs_jpim1 ! vector opt.
- ikt=mikt(ji,jj) ; iktp1i=mikt(ji+1,jj); iktp1j=mikt(ji,jj+1)
- ! hydrostatic pressure gradient along s-surfaces and ice shelf pressure
- ! we assume ISF is in isostatic equilibrium
- zhpi(ji,jj,1) = zcoef0 / e1u(ji,jj) * ( 0.5_wp * fse3w(ji+1,jj ,iktp1i) &
- & * ( 2._wp * znad + rhd(ji+1,jj ,iktp1i) + zrhdtop_oce(ji+1,jj ) ) &
- & - 0.5_wp * fse3w(ji ,jj ,ikt ) &
- & * ( 2._wp * znad + rhd(ji ,jj ,ikt ) + zrhdtop_oce(ji ,jj ) ) &
- & + ( ziceload(ji+1,jj) - ziceload(ji,jj)) )
- zhpj(ji,jj,1) = zcoef0 / e2v(ji,jj) * ( 0.5_wp * fse3w(ji ,jj+1,iktp1j) &
- & * ( 2._wp * znad + rhd(ji ,jj+1,iktp1j) + zrhdtop_oce(ji ,jj+1) ) &
- & - 0.5_wp * fse3w(ji ,jj ,ikt ) &
- & * ( 2._wp * znad + rhd(ji ,jj ,ikt ) + zrhdtop_oce(ji ,jj ) ) &
- & + ( ziceload(ji,jj+1) - ziceload(ji,jj) ) )
- ! s-coordinate pressure gradient correction (=0 if z coordinate)
- zuap = -zcoef0 * ( rhd (ji+1,jj,1) + rhd (ji,jj,1) + 2._wp * znad ) &
- & * ( fsde3w(ji+1,jj,1) - fsde3w(ji,jj,1) ) / e1u(ji,jj)
- zvap = -zcoef0 * ( rhd (ji,jj+1,1) + rhd (ji,jj,1) + 2._wp * znad ) &
- & * ( fsde3w(ji,jj+1,1) - fsde3w(ji,jj,1) ) / e2v(ji,jj)
- ! add to the general momentum trend
- ua(ji,jj,1) = ua(ji,jj,1) + (zhpi(ji,jj,1) + zuap) * umask(ji,jj,1)
- va(ji,jj,1) = va(ji,jj,1) + (zhpj(ji,jj,1) + zvap) * vmask(ji,jj,1)
- END DO
- END DO
- !==================================================================================
- !===== Compute partial cell contribution for the top cell =========================
- !==================================================================================
- DO jj = 2, jpjm1
- DO ji = fs_2, fs_jpim1 ! vector opt.
- iku = miku(ji,jj) ;
- zpshpi(ji,jj)=0.0_wp ; zpshpj(ji,jj)=0.0_wp
- ze3wu = (gdepw_0(ji+1,jj,iku+1) - gdept_0(ji+1,jj,iku)) - (gdepw_0(ji,jj,iku+1) - gdept_0(ji,jj,iku))
- ! u direction
- IF ( iku .GT. 1 ) THEN
- ! case iku
- zhpi(ji,jj,iku) = zcoef0 / e1u(ji,jj) * ze3wu &
- & * ( rhd (ji+1,jj,iku) + rhd (ji,jj,iku) &
- & + SIGN(1._wp,ze3wu) * grui(ji,jj) + 2._wp * znad )
- ! corrective term ( = 0 if z coordinate )
- zuap = -zcoef0 * ( arui(ji,jj) + 2._wp * znad ) * gzui(ji,jj) / e1u(ji,jj)
- ! zhpi will be added in interior loop
- ua(ji,jj,iku) = ua(ji,jj,iku) + zuap
- ! in case of 2 cell water column, need to save the pressure gradient to compute the bottom pressure
- IF (mbku(ji,jj) == iku + 1) zpshpi(ji,jj) = zhpi(ji,jj,iku)
- ! case iku + 1 (remove the zphi term added in the interior loop and compute the one corrected for zps)
- zhpiint = zcoef0 / e1u(ji,jj) &
- & * ( fse3w(ji+1,jj ,iku+1) * ( (rhd(ji+1,jj,iku+1) + znad) &
- & + (rhd(ji+1,jj,iku ) + znad) ) * tmask(ji+1,jj,iku) &
- & - fse3w(ji ,jj ,iku+1) * ( (rhd(ji ,jj,iku+1) + znad) &
- & + (rhd(ji ,jj,iku ) + znad) ) * tmask(ji ,jj,iku) )
- zhpi(ji,jj,iku+1) = zcoef0 / e1u(ji,jj) * ge3rui(ji,jj) - zhpiint
- END IF
-
- ! v direction
- ikv = mikv(ji,jj)
- ze3wv = (gdepw_0(ji,jj+1,ikv+1) - gdept_0(ji,jj+1,ikv)) - (gdepw_0(ji,jj,ikv+1) - gdept_0(ji,jj,ikv))
- IF ( ikv .GT. 1 ) THEN
- ! case ikv
- zhpj(ji,jj,ikv) = zcoef0 / e2v(ji,jj) * ze3wv &
- & * ( rhd(ji,jj+1,ikv) + rhd (ji,jj,ikv) &
- & + SIGN(1._wp,ze3wv) * grvi(ji,jj) + 2._wp * znad )
- ! corrective term ( = 0 if z coordinate )
- zvap = -zcoef0 * ( arvi(ji,jj) + 2._wp * znad ) * gzvi(ji,jj) / e2v(ji,jj)
- ! zhpi will be added in interior loop
- va(ji,jj,ikv) = va(ji,jj,ikv) + zvap
- ! in case of 2 cell water column, need to save the pressure gradient to compute the bottom pressure
- IF (mbkv(ji,jj) == ikv + 1) zpshpj(ji,jj) = zhpj(ji,jj,ikv)
-
- ! case ikv + 1 (remove the zphj term added in the interior loop and compute the one corrected for zps)
- zhpjint = zcoef0 / e2v(ji,jj) &
- & * ( fse3w(ji ,jj+1,ikv+1) * ( (rhd(ji,jj+1,ikv+1) + znad) &
- & + (rhd(ji,jj+1,ikv ) + znad) ) * tmask(ji,jj+1,ikv) &
- & - fse3w(ji ,jj ,ikv+1) * ( (rhd(ji,jj ,ikv+1) + znad) &
- & + (rhd(ji,jj ,ikv ) + znad) ) * tmask(ji,jj ,ikv) )
- zhpj(ji,jj,ikv+1) = zcoef0 / e2v(ji,jj) * ge3rvi(ji,jj) - zhpjint
- END IF
- END DO
- END DO
- !==================================================================================
- !===== Compute interior value =====================================================
- !==================================================================================
- DO jj = 2, jpjm1
- DO ji = fs_2, fs_jpim1 ! vector opt.
- iku=miku(ji,jj); ikv=mikv(ji,jj)
- DO jk = 2, jpkm1
- ! hydrostatic pressure gradient along s-surfaces
- ! zhpi is masked for the first wet cell (contribution already done in the upper bloc)
- zhpi(ji,jj,jk) = zhpi(ji,jj,jk) + zhpi(ji,jj,jk-1) &
- & + zcoef0 / e1u(ji,jj) &
- & * ( fse3w(ji+1,jj ,jk) * ( (rhd(ji+1,jj,jk ) + znad) &
- & + (rhd(ji+1,jj,jk-1) + znad) ) * tmask(ji+1,jj,jk-1) &
- & - fse3w(ji ,jj ,jk) * ( (rhd(ji ,jj,jk ) + znad) &
- & + (rhd(ji ,jj,jk-1) + znad) ) * tmask(ji ,jj,jk-1) )
- ! s-coordinate pressure gradient correction
- ! corrective term, we mask this term for the first wet level beneath the ice shelf (contribution done in the upper bloc)
- zuap = - zcoef0 * ( rhd (ji+1,jj ,jk) + rhd (ji,jj,jk) + 2._wp * znad ) &
- & * ( fsde3w(ji+1,jj ,jk) - fsde3w(ji,jj,jk) ) / e1u(ji,jj) * umask(ji,jj,jk-1)
- ua(ji,jj,jk) = ua(ji,jj,jk) + ( zhpi(ji,jj,jk) + zuap) * umask(ji,jj,jk)
- ! hydrostatic pressure gradient along s-surfaces
- ! zhpi is masked for the first wet cell (contribution already done in the upper bloc)
- zhpj(ji,jj,jk) = zhpj(ji,jj,jk) + zhpj(ji,jj,jk-1) &
- & + zcoef0 / e2v(ji,jj) &
- & * ( fse3w(ji ,jj+1,jk) * ( (rhd(ji,jj+1,jk ) + znad) &
- & + (rhd(ji,jj+1,jk-1) + znad) ) * tmask(ji,jj+1,jk-1) &
- & - fse3w(ji ,jj ,jk) * ( (rhd(ji,jj ,jk ) + znad) &
- & + (rhd(ji,jj ,jk-1) + znad) ) * tmask(ji,jj ,jk-1) )
- ! s-coordinate pressure gradient correction
- ! corrective term, we mask this term for the first wet level beneath the ice shelf (contribution done in the upper bloc)
- zvap = - zcoef0 * ( rhd (ji ,jj+1,jk) + rhd (ji,jj,jk) + 2._wp * znad ) &
- & * ( fsde3w(ji ,jj+1,jk) - fsde3w(ji,jj,jk) ) / e2v(ji,jj) * vmask(ji,jj,jk-1)
- ! add to the general momentum trend
- va(ji,jj,jk) = va(ji,jj,jk) + ( zhpj(ji,jj,jk) + zvap ) * vmask(ji,jj,jk)
- END DO
- END DO
- END DO
- !==================================================================================
- !===== Compute bottom cell contribution (partial cell) ============================
- !==================================================================================
- DO jj = 2, jpjm1
- DO ji = 2, jpim1
- iku = mbku(ji,jj)
- ikv = mbkv(ji,jj)
- IF (iku .GT. 1) THEN
- ! remove old value (interior case)
- zuap = -zcoef0 * ( rhd (ji+1,jj ,iku) + rhd (ji,jj,iku) + 2._wp * znad ) &
- & * ( fsde3w(ji+1,jj ,iku) - fsde3w(ji,jj,iku) ) / e1u(ji,jj)
- ua(ji,jj,iku) = ua(ji,jj,iku) - zhpi(ji,jj,iku) - zuap
- ! put new value
- ! -zpshpi to avoid double contribution of the partial step in the top layer
- zuap = -zcoef0 * ( aru(ji,jj) + 2._wp * znad ) * gzu(ji,jj) / e1u(ji,jj)
- zhpi(ji,jj,iku) = zhpi(ji,jj,iku-1) + zcoef0 / e1u(ji,jj) * ge3ru(ji,jj) - zpshpi(ji,jj)
- ua(ji,jj,iku) = ua(ji,jj,iku) + zhpi(ji,jj,iku) + zuap
- END IF
- ! v direction
- IF (ikv .GT. 1) THEN
- ! remove old value (interior case)
- zvap = -zcoef0 * ( rhd (ji ,jj+1,ikv) + rhd (ji,jj,ikv) + 2._wp * znad ) &
- & * ( fsde3w(ji ,jj+1,ikv) - fsde3w(ji,jj,ikv) ) / e2v(ji,jj)
- va(ji,jj,ikv) = va(ji,jj,ikv) - zhpj(ji,jj,ikv) - zvap
- ! put new value
- ! -zpshpj to avoid double contribution of the partial step in the top layer
- zvap = -zcoef0 * ( arv(ji,jj) + 2._wp * znad ) * gzv(ji,jj) / e2v(ji,jj)
- zhpj(ji,jj,ikv) = zhpj(ji,jj,ikv-1) + zcoef0 / e2v(ji,jj) * ge3rv(ji,jj) - zpshpj(ji,jj)
- va(ji,jj,ikv) = va(ji,jj,ikv) + zhpj(ji,jj,ikv) + zvap
- END IF
- END DO
- END DO
-
- ! set back to original density value into the ice shelf cell (maybe useless because it is masked)
- rhd = zrhd
- !
- CALL wrk_dealloc( jpi,jpj,2, ztstop)
- CALL wrk_dealloc( jpi,jpj,jpk, zhpi, zhpj, zrhd)
- CALL wrk_dealloc( jpi,jpj, ze3w, zp, zrhdtop_isf, zrhdtop_oce, ziceload, zdept, zpshpi, zpshpj)
- !
- END SUBROUTINE hpg_isf
- SUBROUTINE hpg_djc( kt )
- !!---------------------------------------------------------------------
- !! *** ROUTINE hpg_djc ***
- !!
- !! ** Method : Density Jacobian with Cubic polynomial scheme
- !!
- !! Reference: Shchepetkin and McWilliams, J. Geophys. Res., 108(C3), 3090, 2003
- !!----------------------------------------------------------------------
- INTEGER, INTENT(in) :: kt ! ocean time-step index
- !!
- INTEGER :: ji, jj, jk ! dummy loop indices
- REAL(wp) :: zcoef0, zep, cffw ! temporary scalars
- REAL(wp) :: z1_10, cffu, cffx ! " "
- REAL(wp) :: z1_12, cffv, cffy ! " "
- REAL(wp), POINTER, DIMENSION(:,:,:) :: zhpi, zhpj
- REAL(wp), POINTER, DIMENSION(:,:,:) :: dzx, dzy, dzz, dzu, dzv, dzw
- REAL(wp), POINTER, DIMENSION(:,:,:) :: drhox, drhoy, drhoz, drhou, drhov, drhow
- REAL(wp), POINTER, DIMENSION(:,:,:) :: rho_i, rho_j, rho_k
- !!----------------------------------------------------------------------
- !
- CALL wrk_alloc( jpi, jpj, jpk, dzx , dzy , dzz , dzu , dzv , dzw )
- CALL wrk_alloc( jpi, jpj, jpk, drhox, drhoy, drhoz, drhou, drhov, drhow )
- CALL wrk_alloc( jpi, jpj, jpk, rho_i, rho_j, rho_k, zhpi, zhpj )
- !
- IF( kt == nit000 ) THEN
- IF(lwp) WRITE(numout,*)
- IF(lwp) WRITE(numout,*) 'dyn:hpg_djc : hydrostatic pressure gradient trend'
- IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ s-coordinate case, density Jacobian with cubic polynomial scheme'
- ENDIF
- ! Local constant initialization
- zcoef0 = - grav * 0.5_wp
- z1_10 = 1._wp / 10._wp
- z1_12 = 1._wp / 12._wp
- !----------------------------------------------------------------------------------------
- ! compute and store in provisional arrays elementary vertical and horizontal differences
- !----------------------------------------------------------------------------------------
- !!bug gm Not a true bug, but... dzz=e3w for dzx, dzy verify what it is really
- DO jk = 2, jpkm1
- DO jj = 2, jpjm1
- DO ji = fs_2, fs_jpim1 ! vector opt.
- drhoz(ji,jj,jk) = rhd (ji ,jj ,jk) - rhd (ji,jj,jk-1)
- dzz (ji,jj,jk) = fsde3w(ji ,jj ,jk) - fsde3w(ji,jj,jk-1)
- drhox(ji,jj,jk) = rhd (ji+1,jj ,jk) - rhd (ji,jj,jk )
- dzx (ji,jj,jk) = fsde3w(ji+1,jj ,jk) - fsde3w(ji,jj,jk )
- drhoy(ji,jj,jk) = rhd (ji ,jj+1,jk) - rhd (ji,jj,jk )
- dzy (ji,jj,jk) = fsde3w(ji ,jj+1,jk) - fsde3w(ji,jj,jk )
- END DO
- END DO
- END DO
- !-------------------------------------------------------------------------
- ! compute harmonic averages using eq. 5.18
- !-------------------------------------------------------------------------
- zep = 1.e-15
- !!bug gm drhoz not defined at level 1 and used (jk-1 with jk=2)
- !!bug gm idem for drhox, drhoy et ji=jpi and jj=jpj
- DO jk = 2, jpkm1
- DO jj = 2, jpjm1
- DO ji = fs_2, fs_jpim1 ! vector opt.
- cffw = 2._wp * drhoz(ji ,jj ,jk) * drhoz(ji,jj,jk-1)
- cffu = 2._wp * drhox(ji+1,jj ,jk) * drhox(ji,jj,jk )
- cffx = 2._wp * dzx (ji+1,jj ,jk) * dzx (ji,jj,jk )
- cffv = 2._wp * drhoy(ji ,jj+1,jk) * drhoy(ji,jj,jk )
- cffy = 2._wp * dzy (ji ,jj+1,jk) * dzy (ji,jj,jk )
- IF( cffw > zep) THEN
- drhow(ji,jj,jk) = 2._wp * drhoz(ji,jj,jk) * drhoz(ji,jj,jk-1) &
- & / ( drhoz(ji,jj,jk) + drhoz(ji,jj,jk-1) )
- ELSE
- drhow(ji,jj,jk) = 0._wp
- ENDIF
- dzw(ji,jj,jk) = 2._wp * dzz(ji,jj,jk) * dzz(ji,jj,jk-1) &
- & / ( dzz(ji,jj,jk) + dzz(ji,jj,jk-1) )
- IF( cffu > zep ) THEN
- drhou(ji,jj,jk) = 2._wp * drhox(ji+1,jj,jk) * drhox(ji,jj,jk) &
- & / ( drhox(ji+1,jj,jk) + drhox(ji,jj,jk) )
- ELSE
- drhou(ji,jj,jk ) = 0._wp
- ENDIF
- IF( cffx > zep ) THEN
- dzu(ji,jj,jk) = 2._wp * dzx(ji+1,jj,jk) * dzx(ji,jj,jk) &
- & / ( dzx(ji+1,jj,jk) + dzx(ji,jj,jk) )
- ELSE
- dzu(ji,jj,jk) = 0._wp
- ENDIF
- IF( cffv > zep ) THEN
- drhov(ji,jj,jk) = 2._wp * drhoy(ji,jj+1,jk) * drhoy(ji,jj,jk) &
- & / ( drhoy(ji,jj+1,jk) + drhoy(ji,jj,jk) )
- ELSE
- drhov(ji,jj,jk) = 0._wp
- ENDIF
- IF( cffy > zep ) THEN
- dzv(ji,jj,jk) = 2._wp * dzy(ji,jj+1,jk) * dzy(ji,jj,jk) &
- & / ( dzy(ji,jj+1,jk) + dzy(ji,jj,jk) )
- ELSE
- dzv(ji,jj,jk) = 0._wp
- ENDIF
- END DO
- END DO
- END DO
- !----------------------------------------------------------------------------------
- ! apply boundary conditions at top and bottom using 5.36-5.37
- !----------------------------------------------------------------------------------
- drhow(:,:, 1 ) = 1.5_wp * ( drhoz(:,:, 2 ) - drhoz(:,:, 1 ) ) - 0.5_wp * drhow(:,:, 2 )
- drhou(:,:, 1 ) = 1.5_wp * ( drhox(:,:, 2 ) - drhox(:,:, 1 ) ) - 0.5_wp * drhou(:,:, 2 )
- drhov(:,:, 1 ) = 1.5_wp * ( drhoy(:,:, 2 ) - drhoy(:,:, 1 ) ) - 0.5_wp * drhov(:,:, 2 )
- drhow(:,:,jpk) = 1.5_wp * ( drhoz(:,:,jpk) - drhoz(:,:,jpkm1) ) - 0.5_wp * drhow(:,:,jpkm1)
- drhou(:,:,jpk) = 1.5_wp * ( drhox(:,:,jpk) - drhox(:,:,jpkm1) ) - 0.5_wp * drhou(:,:,jpkm1)
- drhov(:,:,jpk) = 1.5_wp * ( drhoy(:,:,jpk) - drhoy(:,:,jpkm1) ) - 0.5_wp * drhov(:,:,jpkm1)
- !--------------------------------------------------------------
- ! Upper half of top-most grid box, compute and store
- !-------------------------------------------------------------
- !!bug gm : e3w-de3w = 0.5*e3w .... and de3w(2)-de3w(1)=e3w(2) .... to be verified
- ! true if de3w is really defined as the sum of the e3w scale factors as, it seems to me, it should be
- DO jj = 2, jpjm1
- DO ji = fs_2, fs_jpim1 ! vector opt.
- rho_k(ji,jj,1) = -grav * ( fse3w(ji,jj,1) - fsde3w(ji,jj,1) ) &
- & * ( rhd(ji,jj,1) &
- & + 0.5_wp * ( rhd(ji,jj,2) - rhd(ji,jj,1) ) &
- & * ( fse3w (ji,jj,1) - fsde3w(ji,jj,1) ) &
- & / ( fsde3w(ji,jj,2) - fsde3w(ji,jj,1) ) )
- END DO
- END DO
- !!bug gm : here also, simplification is possible
- !!bug gm : optimisation: 1/10 and 1/12 the division should be done before the loop
- DO jk = 2, jpkm1
- DO jj = 2, jpjm1
- DO ji = fs_2, fs_jpim1 ! vector opt.
- rho_k(ji,jj,jk) = zcoef0 * ( rhd (ji,jj,jk) + rhd (ji,jj,jk-1) ) &
- & * ( fsde3w(ji,jj,jk) - fsde3w(ji,jj,jk-1) ) &
- & - grav * z1_10 * ( &
- & ( drhow (ji,jj,jk) - drhow (ji,jj,jk-1) ) &
- & * ( fsde3w(ji,jj,jk) - fsde3w(ji,jj,jk-1) - z1_12 * ( dzw (ji,jj,jk) + dzw (ji,jj,jk-1) ) ) &
- & - ( dzw (ji,jj,jk) - dzw (ji,jj,jk-1) ) &
- & * ( rhd (ji,jj,jk) - rhd (ji,jj,jk-1) - z1_12 * ( drhow(ji,jj,jk) + drhow(ji,jj,jk-1) ) ) &
- & )
- rho_i(ji,jj,jk) = zcoef0 * ( rhd (ji+1,jj,jk) + rhd (ji,jj,jk) ) &
- & * ( fsde3w(ji+1,jj,jk) - fsde3w(ji,jj,jk) ) &
- & - grav* z1_10 * ( &
- & ( drhou (ji+1,jj,jk) - drhou (ji,jj,jk) ) &
- & * ( fsde3w(ji+1,jj,jk) - fsde3w(ji,jj,jk) - z1_12 * ( dzu (ji+1,jj,jk) + dzu (ji,jj,jk) ) ) &
- & - ( dzu (ji+1,jj,jk) - dzu (ji,jj,jk) ) &
- & * ( rhd (ji+1,jj,jk) - rhd (ji,jj,jk) - z1_12 * ( drhou(ji+1,jj,jk) + drhou(ji,jj,jk) ) ) &
- & )
- rho_j(ji,jj,jk) = zcoef0 * ( rhd (ji,jj+1,jk) + rhd (ji,jj,jk) ) &
- & * ( fsde3w(ji,jj+1,jk) - fsde3w(ji,jj,jk) ) &
- & - grav* z1_10 * ( &
- & ( drhov (ji,jj+1,jk) - drhov (ji,jj,jk) ) &
- & * ( fsde3w(ji,jj+1,jk) - fsde3w(ji,jj,jk) - z1_12 * ( dzv (ji,jj+1,jk) + dzv (ji,jj,jk) ) ) &
- & - ( dzv (ji,jj+1,jk) - dzv (ji,jj,jk) ) &
- & * ( rhd (ji,jj+1,jk) - rhd (ji,jj,jk) - z1_12 * ( drhov(ji,jj+1,jk) + drhov(ji,jj,jk) ) ) &
- & )
- END DO
- END DO
- END DO
- CALL lbc_lnk(rho_k,'W',1.)
- CALL lbc_lnk(rho_i,'U',1.)
- CALL lbc_lnk(rho_j,'V',1.)
- ! ---------------
- ! Surface value
- ! ---------------
- DO jj = 2, jpjm1
- DO ji = fs_2, fs_jpim1 ! vector opt.
- zhpi(ji,jj,1) = ( rho_k(ji+1,jj ,1) - rho_k(ji,jj,1) - rho_i(ji,jj,1) ) / e1u(ji,jj)
- zhpj(ji,jj,1) = ( rho_k(ji ,jj+1,1) - rho_k(ji,jj,1) - rho_j(ji,jj,1) ) / e2v(ji,jj)
- ! add to the general momentum trend
- ua(ji,jj,1) = ua(ji,jj,1) + zhpi(ji,jj,1)
- va(ji,jj,1) = va(ji,jj,1) + zhpj(ji,jj,1)
- END DO
- END DO
- ! ----------------
- ! interior value (2=<jk=<jpkm1)
- ! ----------------
- DO jk = 2, jpkm1
- DO jj = 2, jpjm1
- DO ji = fs_2, fs_jpim1 ! vector opt.
- ! hydrostatic pressure gradient along s-surfaces
- zhpi(ji,jj,jk) = zhpi(ji,jj,jk-1) &
- & + ( ( rho_k(ji+1,jj,jk) - rho_k(ji,jj,jk ) ) &
- & - ( rho_i(ji ,jj,jk) - rho_i(ji,jj,jk-1) ) ) / e1u(ji,jj)
- zhpj(ji,jj,jk) = zhpj(ji,jj,jk-1) &
- & + ( ( rho_k(ji,jj+1,jk) - rho_k(ji,jj,jk ) ) &
- & -( rho_j(ji,jj ,jk) - rho_j(ji,jj,jk-1) ) ) / e2v(ji,jj)
- ! add to the general momentum trend
- ua(ji,jj,jk) = ua(ji,jj,jk) + zhpi(ji,jj,jk)
- va(ji,jj,jk) = va(ji,jj,jk) + zhpj(ji,jj,jk)
- END DO
- END DO
- END DO
- !
- CALL wrk_dealloc( jpi, jpj, jpk, dzx , dzy , dzz , dzu , dzv , dzw )
- CALL wrk_dealloc( jpi, jpj, jpk, drhox, drhoy, drhoz, drhou, drhov, drhow )
- CALL wrk_dealloc( jpi, jpj, jpk, rho_i, rho_j, rho_k, zhpi, zhpj )
- !
- END SUBROUTINE hpg_djc
- SUBROUTINE hpg_prj( kt )
- !!---------------------------------------------------------------------
- !! *** ROUTINE hpg_prj ***
- !!
- !! ** Method : s-coordinate case.
- !! A Pressure-Jacobian horizontal pressure gradient method
- !! based on the constrained cubic-spline interpolation for
- !! all vertical coordinate systems
- !!
- !! ** Action : - Update (ua,va) with the now hydrastatic pressure trend
- !!----------------------------------------------------------------------
- INTEGER, PARAMETER :: polynomial_type = 1 ! 1: cubic spline, 2: linear
- INTEGER, INTENT(in) :: kt ! ocean time-step index
- !!
- INTEGER :: ji, jj, jk, jkk ! dummy loop indices
- REAL(wp) :: zcoef0, znad ! temporary scalars
- !!
- !! The local variables for the correction term
- INTEGER :: jk1, jis, jid, jjs, jjd
- REAL(wp) :: zuijk, zvijk, zpwes, zpwed, zpnss, zpnsd, zdeps
- REAL(wp) :: zrhdt1
- REAL(wp) :: zdpdx1, zdpdx2, zdpdy1, zdpdy2
- REAL(wp), POINTER, DIMENSION(:,:,:) :: zdept, zrhh
- REAL(wp), POINTER, DIMENSION(:,:,:) :: zhpi, zu, zv, fsp, xsp, asp, bsp, csp, dsp
- REAL(wp), POINTER, DIMENSION(:,:) :: zsshu_n, zsshv_n
- !!----------------------------------------------------------------------
- !
- CALL wrk_alloc( jpi,jpj,jpk, zhpi, zu, zv, fsp, xsp, asp, bsp, csp, dsp )
- CALL wrk_alloc( jpi,jpj,jpk, zdept, zrhh )
- CALL wrk_alloc( jpi,jpj, zsshu_n, zsshv_n )
- !
- IF( kt == nit000 ) THEN
- IF(lwp) WRITE(numout,*)
- IF(lwp) WRITE(numout,*) 'dyn:hpg_prj : hydrostatic pressure gradient trend'
- IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ s-coordinate case, cubic spline pressure Jacobian'
- ENDIF
- !!----------------------------------------------------------------------
- ! Local constant initialization
- zcoef0 = - grav
- znad = 0.0_wp
- IF( lk_vvl ) znad = 1._wp
- ! Clean 3-D work arrays
- zhpi(:,:,:) = 0._wp
- zrhh(:,:,:) = rhd(:,:,:)
- ! Preparing vertical density profile "zrhh(:,:,:)" for hybrid-sco coordinate
- DO jj = 1, jpj
- DO ji = 1, jpi
- jk = mbathy(ji,jj)
- IF( jk <= 0 ) THEN; zrhh(ji,jj,:) = 0._wp
- ELSE IF(jk == 1) THEN; zrhh(ji,jj, jk+1:jpk) = rhd(ji,jj,jk)
- ELSE IF(jk < jpkm1) THEN
- DO jkk = jk+1, jpk
- zrhh(ji,jj,jkk) = interp1(fsde3w(ji,jj,jkk), fsde3w(ji,jj,jkk-1), &
- fsde3w(ji,jj,jkk-2), rhd(ji,jj,jkk-1), rhd(ji,jj,jkk-2))
- END DO
- ENDIF
- END DO
- END DO
- ! Transfer the depth of "T(:,:,:)" to vertical coordinate "zdept(:,:,:)"
- DO jj = 1, jpj
- DO ji = 1, jpi
- zdept(ji,jj,1) = 0.5_wp * fse3w(ji,jj,1) - sshn(ji,jj) * znad
- END DO
- END DO
- DO jk = 2, jpk
- DO jj = 1, jpj
- DO ji = 1, jpi
- zdept(ji,jj,jk) = zdept(ji,jj,jk-1) + fse3w(ji,jj,jk)
- END DO
- END DO
- END DO
- fsp(:,:,:) = zrhh (:,:,:)
- xsp(:,:,:) = zdept(:,:,:)
- ! Construct the vertical density profile with the
- ! constrained cubic spline interpolation
- ! rho(z) = asp + bsp*z + csp*z^2 + dsp*z^3
- CALL cspline(fsp,xsp,asp,bsp,csp,dsp,polynomial_type)
- ! Integrate the hydrostatic pressure "zhpi(:,:,:)" at "T(ji,jj,1)"
- DO jj = 2, jpj
- DO ji = 2, jpi
- zrhdt1 = zrhh(ji,jj,1) - interp3(zdept(ji,jj,1),asp(ji,jj,1), &
- bsp(ji,jj,1), csp(ji,jj,1), &
- dsp(ji,jj,1) ) * 0.25_wp * fse3w(ji,jj,1)
- ! assuming linear profile across the top half surface layer
- zhpi(ji,jj,1) = 0.5_wp * fse3w(ji,jj,1) * zrhdt1
- END DO
- END DO
- ! Calculate the pressure "zhpi(:,:,:)" at "T(ji,jj,2:jpkm1)"
- DO jk = 2, jpkm1
- DO jj = 2, jpj
- DO ji = 2, jpi
- zhpi(ji,jj,jk) = zhpi(ji,jj,jk-1) + &
- integ_spline(zdept(ji,jj,jk-1), zdept(ji,jj,jk),&
- asp(ji,jj,jk-1), bsp(ji,jj,jk-1), &
- csp(ji,jj,jk-1), dsp(ji,jj,jk-1))
- END DO
- END DO
- END DO
- ! Z coordinate of U(ji,jj,1:jpkm1) and V(ji,jj,1:jpkm1)
- ! Prepare zsshu_n and zsshv_n
- DO jj = 2, jpjm1
- DO ji = 2, jpim1
- zsshu_n(ji,jj) = (e12u(ji,jj) * sshn(ji,jj) + e12u(ji+1, jj) * sshn(ji+1,jj)) * &
- & r1_e12u(ji,jj) * umask(ji,jj,1) * 0.5_wp
- zsshv_n(ji,jj) = (e12v(ji,jj) * sshn(ji,jj) + e12v(ji+1, jj) * sshn(ji,jj+1)) * &
- & r1_e12v(ji,jj) * vmask(ji,jj,1) * 0.5_wp
- END DO
- END DO
- DO jj = 2, jpjm1
- DO ji = 2, jpim1
- zu(ji,jj,1) = - ( fse3u(ji,jj,1) - zsshu_n(ji,jj) * znad)
- zv(ji,jj,1) = - ( fse3v(ji,jj,1) - zsshv_n(ji,jj) * znad)
- END DO
- END DO
- DO jk = 2, jpkm1
- DO jj = 2, jpjm1
- DO ji = 2, jpim1
- zu(ji,jj,jk) = zu(ji,jj,jk-1)- fse3u(ji,jj,jk)
- zv(ji,jj,jk) = zv(ji,jj,jk-1)- fse3v(ji,jj,jk)
- END DO
- END DO
- END DO
- DO jk = 1, jpkm1
- DO jj = 2, jpjm1
- DO ji = 2, jpim1
- zu(ji,jj,jk) = zu(ji,jj,jk) + 0.5_wp * fse3u(ji,jj,jk)
- zv(ji,jj,jk) = zv(ji,jj,jk) + 0.5_wp * fse3v(ji,jj,jk)
- END DO
- END DO
- END DO
- DO jk = 1, jpkm1
- DO jj = 2, jpjm1
- DO ji = 2, jpim1
- zu(ji,jj,jk) = min(zu(ji,jj,jk), max(-zdept(ji,jj,jk), -zdept(ji+1,jj,jk)))
- zu(ji,jj,jk) = max(zu(ji,jj,jk), min(-zdept(ji,jj,jk), -zdept(ji+1,jj,jk)))
- zv(ji,jj,jk) = min(zv(ji,jj,jk), max(-zdept(ji,jj,jk), -zdept(ji,jj+1,jk)))
- zv(ji,jj,jk) = max(zv(ji,jj,jk), min(-zdept(ji,jj,jk), -zdept(ji,jj+1,jk)))
- END DO
- END DO
- END DO
- DO jk = 1, jpkm1
- DO jj = 2, jpjm1
- DO ji = 2, jpim1
- zpwes = 0._wp; zpwed = 0._wp
- zpnss = 0._wp; zpnsd = 0._wp
- zuijk = zu(ji,jj,jk)
- zvijk = zv(ji,jj,jk)
- !!!!! for u equation
- IF( jk <= mbku(ji,jj) ) THEN
- IF( -zdept(ji+1,jj,jk) >= -zdept(ji,jj,jk) ) THEN
- jis = ji + 1; jid = ji
- ELSE
- jis = ji; jid = ji +1
- ENDIF
- ! integrate the pressure on the shallow side
- jk1 = jk
- DO WHILE ( -zdept(jis,jj,jk1) > zuijk )
- IF( jk1 == mbku(ji,jj) ) THEN
- zuijk = -zdept(jis,jj,jk1)
- EXIT
- ENDIF
- zdeps = MIN(zdept(jis,jj,jk1+1), -zuijk)
- zpwes = zpwes + &
- integ_spline(zdept(jis,jj,jk1), zdeps, &
- asp(jis,jj,jk1), bsp(jis,jj,jk1), &
- csp(jis,jj,jk1), dsp(jis,jj,jk1))
- jk1 = jk1 + 1
- END DO
- ! integrate the pressure on the deep side
- jk1 = jk
- DO WHILE ( -zdept(jid,jj,jk1) < zuijk )
- IF( jk1 == 1 ) THEN
- zdeps = zdept(jid,jj,1) + MIN(zuijk, sshn(jid,jj)*znad)
- zrhdt1 = zrhh(jid,jj,1) - interp3(zdept(jid,jj,1), asp(jid,jj,1), &
- bsp(jid,jj,1), csp(jid,jj,1), &
- dsp(jid,jj,1)) * zdeps
- zpwed = zpwed + 0.5_wp * (zrhh(jid,jj,1) + zrhdt1) * zdeps
- EXIT
- ENDIF
- zdeps = MAX(zdept(jid,jj,jk1-1), -zuijk)
- zpwed = zpwed + &
- integ_spline(zdeps, zdept(jid,jj,jk1), &
- asp(jid,jj,jk1-1), bsp(jid,jj,jk1-1), &
- csp(jid,jj,jk1-1), dsp(jid,jj,jk1-1) )
- jk1 = jk1 - 1
- END DO
- ! update the momentum trends in u direction
- zdpdx1 = zcoef0 / e1u(ji,jj) * (zhpi(ji+1,jj,jk) - zhpi(ji,jj,jk))
- IF( lk_vvl ) THEN
- zdpdx2 = zcoef0 / e1u(ji,jj) * &
- ( REAL(jis-jid, wp) * (zpwes + zpwed) + (sshn(ji+1,jj)-sshn(ji,jj)) )
- ELSE
- zdpdx2 = zcoef0 / e1u(ji,jj) * REAL(jis-jid, wp) * (zpwes + zpwed)
- ENDIF
- ua(ji,jj,jk) = ua(ji,jj,jk) + (zdpdx1 + zdpdx2) * &
- & umask(ji,jj,jk) * tmask(ji,jj,jk) * tmask(ji+1,jj,jk)
- ENDIF
- !!!!! for v equation
- IF( jk <= mbkv(ji,jj) ) THEN
- IF( -zdept(ji,jj+1,jk) >= -zdept(ji,jj,jk) ) THEN
- jjs = jj + 1; jjd = jj
- ELSE
- jjs = jj ; jjd = jj + 1
- ENDIF
- ! integrate the pressure on the shallow side
- jk1 = jk
- DO WHILE ( -zdept(ji,jjs,jk1) > zvijk )
- IF( jk1 == mbkv(ji,jj) ) THEN
- zvijk = -zdept(ji,jjs,jk1)
- EXIT
- ENDIF
- zdeps = MIN(zdept(ji,jjs,jk1+1), -zvijk)
- zpnss = zpnss + &
- integ_spline(zdept(ji,jjs,jk1), zdeps, &
- asp(ji,jjs,jk1), bsp(ji,jjs,jk1), &
- csp(ji,jjs,jk1), dsp(ji,jjs,jk1) )
- jk1 = jk1 + 1
- END DO
- ! integrate the pressure on the deep side
- jk1 = jk
- DO WHILE ( -zdept(ji,jjd,jk1) < zvijk )
- IF( jk1 == 1 ) THEN
- zdeps = zdept(ji,jjd,1) + MIN(zvijk, sshn(ji,jjd)*znad)
- zrhdt1 = zrhh(ji,jjd,1) - interp3(zdept(ji,jjd,1), asp(ji,jjd,1), &
- bsp(ji,jjd,1), csp(ji,jjd,1), &
- dsp(ji,jjd,1) ) * zdeps
- zpnsd = zpnsd + 0.5_wp * (zrhh(ji,jjd,1) + zrhdt1) * zdeps
- EXIT
- ENDIF
- zdeps = MAX(zdept(ji,jjd,jk1-1), -zvijk)
- zpnsd = zpnsd + &
- integ_spline(zdeps, zdept(ji,jjd,jk1), &
- asp(ji,jjd,jk1-1), bsp(ji,jjd,jk1-1), &
- csp(ji,jjd,jk1-1), dsp(ji,jjd,jk1-1) )
- jk1 = jk1 - 1
- END DO
- ! update the momentum trends in v direction
- zdpdy1 = zcoef0 / e2v(ji,jj) * (zhpi(ji,jj+1,jk) - zhpi(ji,jj,jk))
- IF( lk_vvl ) THEN
- zdpdy2 = zcoef0 / e2v(ji,jj) * &
- ( REAL(jjs-jjd, wp) * (zpnss + zpnsd) + (sshn(ji,jj+1)-sshn(ji,jj)) )
- ELSE
- zdpdy2 = zcoef0 / e2v(ji,jj) * REAL(jjs-jjd, wp) * (zpnss + zpnsd )
- ENDIF
- va(ji,jj,jk) = va(ji,jj,jk) + (zdpdy1 + zdpdy2)*&
- & vmask(ji,jj,jk)*tmask(ji,jj,jk)*tmask(ji,jj+1,jk)
- ENDIF
- END DO
- END DO
- END DO
- !
- CALL wrk_dealloc( jpi,jpj,jpk, zhpi, zu, zv, fsp, xsp, asp, bsp, csp, dsp )
- CALL wrk_dealloc( jpi,jpj,jpk, zdept, zrhh )
- CALL wrk_dealloc( jpi,jpj, zsshu_n, zsshv_n )
- !
- END SUBROUTINE hpg_prj
- SUBROUTINE cspline(fsp, xsp, asp, bsp, csp, dsp, polynomial_type)
- !!----------------------------------------------------------------------
- !! *** ROUTINE cspline ***
- !!
- !! ** Purpose : constrained cubic spline interpolation
- !!
- !! ** Method : f(x) = asp + bsp*x + csp*x^2 + dsp*x^3
- !!
- !! Reference: CJC Kruger, Constrained Cubic Spline Interpoltation
- !!----------------------------------------------------------------------
- IMPLICIT NONE
- REAL(wp), DIMENSION(:,:,:), INTENT(in) :: fsp, xsp ! value and coordinate
- REAL(wp), DIMENSION(:,:,:), INTENT(out) :: asp, bsp, csp, dsp ! coefficients of
- ! the interpoated function
- INTEGER, INTENT(in) :: polynomial_type ! 1: cubic spline
- ! 2: Linear
- !
- INTEGER :: ji, jj, jk ! dummy loop indices
- INTEGER :: jpi, jpj, jpkm1
- REAL(wp) :: zdf1, zdf2, zddf1, zddf2, ztmp1, ztmp2, zdxtmp
- REAL(wp) :: zdxtmp1, zdxtmp2, zalpha
- REAL(wp) :: zdf(size(fsp,3))
- !!----------------------------------------------------------------------
- jpi = size(fsp,1)
- jpj = size(fsp,2)
- jpkm1 = size(fsp,3) - 1
- IF (polynomial_type == 1) THEN ! Constrained Cubic Spline
- DO ji = 1, jpi
- DO jj = 1, jpj
- !!Fritsch&Butland's method, 1984 (preferred, but more computation)
- ! DO jk = 2, jpkm1-1
- ! zdxtmp1 = xsp(ji,jj,jk) - xsp(ji,jj,jk-1)
- ! zdxtmp2 = xsp(ji,jj,jk+1) - xsp(ji,jj,jk)
- ! zdf1 = ( fsp(ji,jj,jk) - fsp(ji,jj,jk-1) ) / zdxtmp1
- ! zdf2 = ( fsp(ji,jj,jk+1) - fsp(ji,jj,jk) ) / zdxtmp2
- !
- ! zalpha = ( zdxtmp1 + 2._wp * zdxtmp2 ) / ( zdxtmp1 + zdxtmp2 ) / 3._wp
- !
- ! IF(zdf1 * zdf2 <= 0._wp) THEN
- ! zdf(jk) = 0._wp
- ! ELSE
- ! zdf(jk) = zdf1 * zdf2 / ( ( 1._wp - zalpha ) * zdf1 + zalpha * zdf2 )
- ! ENDIF
- ! END DO
- !!Simply geometric average
- DO jk = 2, jpkm1-1
- zdf1 = (fsp(ji,jj,jk) - fsp(ji,jj,jk-1)) / (xsp(ji,jj,jk) - xsp(ji,jj,jk-1))
- zdf2 = (fsp(ji,jj,jk+1) - fsp(ji,jj,jk)) / (xsp(ji,jj,jk+1) - xsp(ji,jj,jk))
- IF(zdf1 * zdf2 <= 0._wp) THEN
- zdf(jk) = 0._wp
- ELSE
- zdf(jk) = 2._wp * zdf1 * zdf2 / (zdf1 + zdf2)
- ENDIF
- END DO
- zdf(1) = 1.5_wp * ( fsp(ji,jj,2) - fsp(ji,jj,1) ) / &
- & ( xsp(ji,jj,2) - xsp(ji,jj,1) ) - 0.5_wp * zdf(2)
- zdf(jpkm1) = 1.5_wp * ( fsp(ji,jj,jpkm1) - fsp(ji,jj,jpkm1-1) ) / &
- & ( xsp(ji,jj,jpkm1) - xsp(ji,jj,jpkm1-1) ) - &
- & 0.5_wp * zdf(jpkm1 - 1)
- DO jk = 1, jpkm1 - 1
- zdxtmp = xsp(ji,jj,jk+1) - xsp(ji,jj,jk)
- ztmp1 = (zdf(jk+1) + 2._wp * zdf(jk)) / zdxtmp
- ztmp2 = 6._wp * (fsp(ji,jj,jk+1) - fsp(ji,jj,jk)) / zdxtmp / zdxtmp
- zddf1 = -2._wp * ztmp1 + ztmp2
- ztmp1 = (2._wp * zdf(jk+1) + zdf(jk)) / zdxtmp
- zddf2 = 2._wp * ztmp1 - ztmp2
- dsp(ji,jj,jk) = (zddf2 - zddf1) / 6._wp / zdxtmp
- csp(ji,jj,jk) = ( xsp(ji,jj,jk+1) * zddf1 - xsp(ji,jj,jk)*zddf2 ) / 2._wp / zdxtmp
- bsp(ji,jj,jk) = ( fsp(ji,jj,jk+1) - fsp(ji,jj,jk) ) / zdxtmp - &
- & csp(ji,jj,jk) * ( xsp(ji,jj,jk+1) + xsp(ji,jj,jk) ) - &
- & dsp(ji,jj,jk) * ((xsp(ji,jj,jk+1) + xsp(ji,jj,jk))**2 - &
- & xsp(ji,jj,jk+1) * xsp(ji,jj,jk))
- asp(ji,jj,jk) = fsp(ji,jj,jk) - xsp(ji,jj,jk) * (bsp(ji,jj,jk) + &
- & (xsp(ji,jj,jk) * (csp(ji,jj,jk) + &
- & dsp(ji,jj,jk) * xsp(ji,jj,jk))))
- END DO
- END DO
- END DO
- ELSE IF (polynomial_type == 2) THEN ! Linear
- DO ji = 1, jpi
- DO jj = 1, jpj
- DO jk = 1, jpkm1-1
- zdxtmp =xsp(ji,jj,jk+1) - xsp(ji,jj,jk)
- ztmp1 = fsp(ji,jj,jk+1) - fsp(ji,jj,jk)
- dsp(ji,jj,jk) = 0._wp
- csp(ji,jj,jk) = 0._wp
- bsp(ji,jj,jk) = ztmp1 / zdxtmp
- asp(ji,jj,jk) = fsp(ji,jj,jk) - bsp(ji,jj,jk) * xsp(ji,jj,jk)
- END DO
- END DO
- END DO
- ELSE
- CALL ctl_stop( 'invalid polynomial type in cspline' )
- ENDIF
- END SUBROUTINE cspline
- FUNCTION interp1(x, xl, xr, fl, fr) RESULT(f)
- !!----------------------------------------------------------------------
- !! *** ROUTINE interp1 ***
- !!
- !! ** Purpose : 1-d linear interpolation
- !!
- !! ** Method : interpolation is straight forward
- !! extrapolation is also permitted (no value limit)
- !!----------------------------------------------------------------------
- IMPLICIT NONE
- REAL(wp), INTENT(in) :: x, xl, xr, fl, fr
- REAL(wp) :: f ! result of the interpolation (extrapolation)
- REAL(wp) :: zdeltx
- !!----------------------------------------------------------------------
- zdeltx = xr - xl
- IF(abs(zdeltx) <= 10._wp * EPSILON(x)) THEN
- f = 0.5_wp * (fl + fr)
- ELSE
- f = ( (x - xl ) * fr - ( x - xr ) * fl ) / zdeltx
- ENDIF
- END FUNCTION interp1
- FUNCTION interp2(x, a, b, c, d) RESULT(f)
- !!----------------------------------------------------------------------
- !! *** ROUTINE interp1 ***
- !!
- !! ** Purpose : 1-d constrained cubic spline interpolation
- !!
- !! ** Method : cubic spline interpolation
- !!
- !!----------------------------------------------------------------------
- IMPLICIT NONE
- REAL(wp), INTENT(in) :: x, a, b, c, d
- REAL(wp) :: f ! value from the interpolation
- !!----------------------------------------------------------------------
- f = a + x* ( b + x * ( c + d * x ) )
- END FUNCTION interp2
- FUNCTION interp3(x, a, b, c, d) RESULT(f)
- !!----------------------------------------------------------------------
- !! *** ROUTINE interp1 ***
- !!
- !! ** Purpose : Calculate the first order of deriavtive of
- !! a cubic spline function y=a+b*x+c*x^2+d*x^3
- !!
- !! ** Method : f=dy/dx=b+2*c*x+3*d*x^2
- !!
- !!----------------------------------------------------------------------
- IMPLICIT NONE
- REAL(wp), INTENT(in) :: x, a, b, c, d
- REAL(wp) :: f ! value from the interpolation
- !!----------------------------------------------------------------------
- f = b + x * ( 2._wp * c + 3._wp * d * x)
- END FUNCTION interp3
- FUNCTION integ_spline(xl, xr, a, b, c, d) RESULT(f)
- !!----------------------------------------------------------------------
- !! *** ROUTINE interp1 ***
- !!
- !! ** Purpose : 1-d constrained cubic spline integration
- !!
- !! ** Method : integrate polynomial a+bx+cx^2+dx^3 from xl to xr
- !!
- !!----------------------------------------------------------------------
- IMPLICIT NONE
- REAL(wp), INTENT(in) :: xl, xr, a, b, c, d
- REAL(wp) :: za1, za2, za3
- REAL(wp) :: f ! integration result
- !!----------------------------------------------------------------------
- za1 = 0.5_wp * b
- za2 = c / 3.0_wp
- za3 = 0.25_wp * d
- f = xr * ( a + xr * ( za1 + xr * ( za2 + za3 * xr ) ) ) - &
- & xl * ( a + xl * ( za1 + xl * ( za2 + za3 * xl ) ) )
- END FUNCTION integ_spline
- !!======================================================================
- END MODULE dynhpg
|