New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
sbcapr.F90 in branches/UKMO/dev_r5518_GO6_under_ice_relax_dr_hook/NEMOGCM/NEMO/OPA_SRC/SBC – NEMO

source: branches/UKMO/dev_r5518_GO6_under_ice_relax_dr_hook/NEMOGCM/NEMO/OPA_SRC/SBC/sbcapr.F90 @ 11738

Last change on this file since 11738 was 11738, checked in by marc, 5 years ago

The Dr Hook changes from my perl code.

File size: 9.7 KB
Line 
1MODULE sbcapr
2   !!======================================================================
3   !!                       ***  MODULE  sbcapr  ***
4   !! Surface module :   atmospheric pressure forcing
5   !!======================================================================
6   !! History :  3.3  !   2010-09  (J. Chanut, C. Bricaud, G. Madec)  Original code
7   !!----------------------------------------------------------------------
8   
9   !!----------------------------------------------------------------------
10   !!   sbc_apr        : read atmospheric pressure in netcdf files
11   !!----------------------------------------------------------------------
12   USE dom_oce         ! ocean space and time domain
13   USE sbc_oce         ! surface boundary condition
14   USE dynspg_oce      ! surface pressure gradient variables
15   USE phycst          ! physical constants
16   USE fldread         ! read input fields
17   USE in_out_manager  ! I/O manager
18   USE lib_fortran     ! distribued memory computing library
19   USE iom             ! IOM library
20   USE lib_mpp         ! MPP library
21   USE timing
22
23   USE yomhook, ONLY: lhook, dr_hook
24   USE parkind1, ONLY: jprb, jpim
25
26   IMPLICIT NONE
27   PRIVATE
28
29   PUBLIC   sbc_apr    ! routine called in sbcmod
30   
31   !                                !!* namsbc_apr namelist (Atmospheric PRessure) *
32   LOGICAL, PUBLIC ::   ln_apr_obc   !: inverse barometer added to OBC ssh data
33   LOGICAL, PUBLIC ::   ln_ref_apr   !: ref. pressure: global mean Patm (F) or a constant (F)
34   REAL(wp)        ::   rn_pref      !  reference atmospheric pressure   [N/m2]
35
36   REAL(wp), ALLOCATABLE, SAVE, PUBLIC, DIMENSION(:,:) ::   ssh_ib    ! Inverse barometer now    sea surface height   [m]
37   REAL(wp), ALLOCATABLE, SAVE, PUBLIC, DIMENSION(:,:) ::   ssh_ibb   ! Inverse barometer before sea surface height   [m]
38   REAL(wp), ALLOCATABLE, SAVE, PUBLIC, DIMENSION(:,:) ::   apr       ! atmospheric pressure at kt                 [N/m2]
39   
40   REAL(wp) ::   tarea                ! whole domain mean masked ocean surface
41   REAL(wp) ::   r1_grau              ! = 1.e0 / (grav * rau0)
42   
43   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_apr   ! structure of input fields (file informations, fields read)
44
45   !! * Substitutions
46#  include "domzgr_substitute.h90"
47   !!----------------------------------------------------------------------
48   !! NEMO/OPA 4.0 , NEMO Consortium (2011)
49   !! $Id$
50   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
51   !!----------------------------------------------------------------------
52CONTAINS
53
54   SUBROUTINE sbc_apr( kt )
55      !!---------------------------------------------------------------------
56      !!                     ***  ROUTINE sbc_apr  ***
57      !!
58      !! ** Purpose :   read atmospheric pressure fields in netcdf files.
59      !!
60      !! ** Method  : - Read namelist namsbc_apr
61      !!              - Read Patm fields in netcdf files
62      !!              - Compute reference atmospheric pressure
63      !!              - Compute inverse barometer ssh
64      !! ** action  :   apr      : atmospheric pressure at kt
65      !!                ssh_ib   : inverse barometer ssh at kt
66      !!---------------------------------------------------------------------
67      INTEGER, INTENT(in)::   kt   ! ocean time step
68      !!
69      INTEGER            ::   ierror  ! local integer
70      INTEGER            ::   ios     ! Local integer output status for namelist read
71      !!
72      CHARACTER(len=100) ::  cn_dir   ! Root directory for location of ssr files
73      TYPE(FLD_N)        ::  sn_apr   ! informations about the fields to be read
74      !!
75      NAMELIST/namsbc_apr/ cn_dir, sn_apr, ln_ref_apr, rn_pref, ln_apr_obc
76      INTEGER(KIND=jpim), PARAMETER :: zhook_in = 0
77      INTEGER(KIND=jpim), PARAMETER :: zhook_out = 1
78      REAL(KIND=jprb)               :: zhook_handle
79
80      CHARACTER(LEN=*), PARAMETER :: RoutineName='SBC_APR'
81
82      IF (lhook) CALL dr_hook(RoutineName,zhook_in,zhook_handle)
83
84      !!----------------------------------------------------------------------
85      !
86      !
87      !                                         ! -------------------- !
88      IF( kt == nit000 ) THEN                   ! First call kt=nit000 !
89         !                                      ! -------------------- !
90         REWIND( numnam_ref )              ! Namelist namsbc_apr in reference namelist : File for atmospheric pressure forcing
91         READ  ( numnam_ref, namsbc_apr, IOSTAT = ios, ERR = 901)
92901      IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_apr in reference namelist', lwp )
93
94         REWIND( numnam_cfg )              ! Namelist namsbc_apr in configuration namelist : File for atmospheric pressure forcing
95         READ  ( numnam_cfg, namsbc_apr, IOSTAT = ios, ERR = 902 )
96902      IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_apr in configuration namelist', lwp )
97         IF(lwm) WRITE ( numond, namsbc_apr )
98         !
99         ALLOCATE( sf_apr(1), STAT=ierror )           !* allocate and fill sf_sst (forcing structure) with sn_sst
100         IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'sbc_apr: unable to allocate sf_apr structure' )
101         !
102         CALL fld_fill( sf_apr, (/ sn_apr /), cn_dir, 'sbc_apr', 'Atmospheric pressure ', 'namsbc_apr' )
103                                ALLOCATE( sf_apr(1)%fnow(jpi,jpj,1)   )
104         IF( sn_apr%ln_tint )   ALLOCATE( sf_apr(1)%fdta(jpi,jpj,1,2) )
105                                ALLOCATE( ssh_ib(jpi,jpj) , ssh_ibb(jpi,jpj) )
106                                ALLOCATE( apr (jpi,jpj) )
107         !
108         IF(lwp) THEN                                 !* control print
109            WRITE(numout,*)
110            WRITE(numout,*) '   Namelist namsbc_apr : Atmospheric PRessure as extrenal forcing'
111            WRITE(numout,*) '      ref. pressure: global mean Patm (T) or a constant (F)  ln_ref_apr = ', ln_ref_apr
112         ENDIF
113         !
114         IF( ln_ref_apr ) THEN                        !* Compute whole inner domain mean masked ocean surface
115            tarea = glob_sum( e1e2t(:,:) )
116            IF(lwp) WRITE(numout,*) '         Variable ref. Patm computed over a ocean surface of ', tarea*1e-6, 'km2'
117         ELSE
118            IF(lwp) WRITE(numout,*) '         Reference Patm used : ', rn_pref, ' N/m2'
119         ENDIF
120         !
121         r1_grau = 1.e0 / (grav * rau0)               !* constant for optimization
122         !
123         !                                            !* control check
124         IF ( ln_apr_obc  ) THEN
125            IF(lwp) WRITE(numout,*) '         Inverse barometer added to OBC ssh data'
126         ENDIF
127         IF( ( ln_apr_obc ) .AND. .NOT. lk_dynspg_ts )   &
128            CALL ctl_stop( 'sbc_apr: use inverse barometer ssh at open boundary ONLY possible with time-splitting' )
129         IF( ( ln_apr_obc ) .AND. .NOT. ln_apr_dyn   )   &
130            CALL ctl_stop( 'sbc_apr: use inverse barometer ssh at open boundary ONLY requires ln_apr_dyn=T' )
131      ENDIF
132
133      !                                         ! ========================== !
134      IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN      !    At each sbc time-step   !
135         !                                      ! ===========+++============ !
136         !
137         IF( kt /= nit000 )   ssh_ibb(:,:) = ssh_ib(:,:)    !* Swap of ssh_ib fields
138         !
139         CALL fld_read( kt, nn_fsbc, sf_apr )               !* input Patm provided at kt + nn_fsbc/2
140         !
141         !                                                  !* update the reference atmospheric pressure (if necessary)
142         IF( ln_ref_apr )   rn_pref = glob_sum( sf_apr(1)%fnow(:,:,1) * e1e2t(:,:) ) / tarea
143         !
144         !                                                  !* Patm related forcing at kt
145         ssh_ib(:,:) = - ( sf_apr(1)%fnow(:,:,1) - rn_pref ) * r1_grau    ! equivalent ssh (inverse barometer)
146         apr   (:,:) =     sf_apr(1)%fnow(:,:,1)                        ! atmospheric pressure
147         !
148         CALL iom_put( "ssh_ib", ssh_ib )                   !* output the inverse barometer ssh
149      ENDIF
150
151      !                                         ! ---------------------------------------- !
152      IF( kt == nit000 ) THEN                   !   set the forcing field at nit000 - 1    !
153         !                                      ! ---------------------------------------- !
154         !                                            !* Restart: read in restart file
155         IF( ln_rstart .AND. iom_varid( numror, 'ssh_ibb', ldstop = .FALSE. ) > 0 ) THEN
156            IF(lwp) WRITE(numout,*) 'sbc_apr:   ssh_ibb read in the restart file'
157            IF(nn_timing == 2)  CALL timing_start('iom_rstget')
158            CALL iom_get( numror, jpdom_autoglo, 'ssh_ibb', ssh_ibb )   ! before inv. barometer ssh
159            IF(nn_timing == 2)  CALL timing_stop('iom_rstget')
160            !
161         ELSE                                         !* no restart: set from nit000 values
162            IF(lwp) WRITE(numout,*) 'sbc_apr:   ssh_ibb set to nit000 values'
163            ssh_ibb(:,:) = ssh_ib(:,:)
164         ENDIF
165      ENDIF
166      !                                         ! ---------------------------------------- !
167      IF( lrst_oce ) THEN                       !      Write in the ocean restart file     !
168         !                                      ! ---------------------------------------- !
169         IF(lwp) WRITE(numout,*)
170         IF(lwp) WRITE(numout,*) 'sbc_apr : ssh_ib written in ocean restart file at it= ', kt,' date= ', ndastp
171         IF(lwp) WRITE(numout,*) '~~~~'
172         IF(nn_timing == 2)  CALL timing_start('iom_rstput')
173         CALL iom_rstput( kt, nitrst, numrow, 'ssh_ibb' , ssh_ib )
174         IF(nn_timing == 2)  CALL timing_stop('iom_rstput')
175      ENDIF
176      !
177      IF (lhook) CALL dr_hook(RoutineName,zhook_out,zhook_handle)
178   END SUBROUTINE sbc_apr
179     
180   !!======================================================================
181END MODULE sbcapr
Note: See TracBrowser for help on using the repository browser.