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 NEMO/trunk/src/OCE/SBC – NEMO

source: NEMO/trunk/src/OCE/SBC/sbcapr.F90 @ 14072

Last change on this file since 14072 was 14072, checked in by laurent, 3 years ago

Merging branch "2020/dev_r13648_ASINTER-04_laurent_bulk_ice", ticket #2369

  • Property svn:keywords set to Id
File size: 9.0 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 phycst          ! physical constants
15   !
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
22   IMPLICIT NONE
23   PRIVATE
24
25   PUBLIC   sbc_apr       ! routine called in sbcmod
26   PUBLIC   sbc_apr_init  ! routine called in sbcmod
27
28   !                                          !!* namsbc_apr namelist (Atmospheric PRessure) *
29   LOGICAL, PUBLIC ::   ln_apr_obc = .false.   !: inverse barometer added to OBC ssh data
30   LOGICAL, PUBLIC ::   ln_ref_apr             !: ref. pressure: global mean Patm (F) or a constant (F)
31   REAL(wp)        ::   rn_pref                !  reference atmospheric pressure   [N/m2]
32
33   REAL(wp), ALLOCATABLE, SAVE, PUBLIC, DIMENSION(:,:) ::   ssh_ib    ! Inverse barometer now    sea surface height   [m]
34   REAL(wp), ALLOCATABLE, SAVE, PUBLIC, DIMENSION(:,:) ::   ssh_ibb   ! Inverse barometer before sea surface height   [m]
35   REAL(wp), ALLOCATABLE, SAVE, PUBLIC, DIMENSION(:,:) ::   apr       ! atmospheric pressure at kt                 [N/m2]
36
37   REAL(wp) ::   tarea                ! whole domain mean masked ocean surface
38   REAL(wp) ::   r1_grau              ! = 1.e0 / (grav * rho0)
39
40   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_apr   ! structure of input fields (file informations, fields read)
41
42   !!----------------------------------------------------------------------
43   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
44   !! $Id$
45   !! Software governed by the CeCILL license (see ./LICENSE)
46   !!----------------------------------------------------------------------
47CONTAINS
48
49   SUBROUTINE sbc_apr_init
50      !!---------------------------------------------------------------------
51      !!                     ***  ROUTINE sbc_apr  ***
52      !!
53      !! ** Purpose :   read atmospheric pressure fields in netcdf files.
54      !!
55      !! ** Method  : - Read namelist namsbc_apr
56      !!              - Read Patm fields in netcdf files
57      !!              - Compute reference atmospheric pressure
58      !!              - Compute inverse barometer ssh
59      !! ** action  :   apr      : atmospheric pressure at kt
60      !!                ssh_ib   : inverse barometer ssh at kt
61      !!---------------------------------------------------------------------
62      INTEGER            ::   ierror  ! local integer
63      INTEGER            ::   ios     ! Local integer output status for namelist read
64      !!
65      CHARACTER(len=100) ::  cn_dir   ! Root directory for location of ssr files
66      TYPE(FLD_N)        ::  sn_apr   ! informations about the fields to be read
67      !!
68      NAMELIST/namsbc_apr/ cn_dir, sn_apr, ln_ref_apr, rn_pref, ln_apr_obc
69      !!----------------------------------------------------------------------
70      READ  ( numnam_ref, namsbc_apr, IOSTAT = ios, ERR = 901)
71901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_apr in reference namelist' )
72
73      READ  ( numnam_cfg, namsbc_apr, IOSTAT = ios, ERR = 902 )
74902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_apr in configuration namelist' )
75      IF(lwm) WRITE ( numond, namsbc_apr )
76      !
77      ALLOCATE( sf_apr(1), STAT=ierror )           !* allocate and fill sf_sst (forcing structure) with sn_sst
78      IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'sbc_apr: unable to allocate sf_apr structure' )
79      !
80      CALL fld_fill( sf_apr, (/ sn_apr /), cn_dir, 'sbc_apr', 'Atmospheric pressure ', 'namsbc_apr' )
81                                ALLOCATE( sf_apr(1)%fnow(jpi,jpj,1)   )
82      IF( sn_apr%ln_tint )   ALLOCATE( sf_apr(1)%fdta(jpi,jpj,1,2) )
83                             ALLOCATE( ssh_ib(jpi,jpj) , ssh_ibb(jpi,jpj) )
84                             ALLOCATE( apr (jpi,jpj) )
85      !
86      IF( lwp )THEN                                 !* control print
87         WRITE(numout,*)
88         WRITE(numout,*) '   Namelist namsbc_apr : Atmospheric PRessure as extrenal forcing'
89         WRITE(numout,*) '      ref. pressure: global mean Patm (T) or a constant (F)  ln_ref_apr = ', ln_ref_apr
90      ENDIF
91      !
92      IF( ln_ref_apr ) THEN                        !* Compute whole inner domain mean masked ocean surface
93         tarea = glob_sum( 'sbcapr', e1e2t(:,:) )
94         IF(lwp) WRITE(numout,*) '         Variable ref. Patm computed over a ocean surface of ', tarea*1e-6, 'km2'
95      ELSE
96         IF(lwp) WRITE(numout,*) '         Reference Patm used : ', rn_pref, ' N/m2'
97      ENDIF
98      !
99      r1_grau = 1.e0 / (grav * rho0)               !* constant for optimization
100      !
101      !                                            !* control check
102      IF( ln_apr_obc  ) THEN
103         IF(lwp) WRITE(numout,*) '         Inverse barometer added to OBC ssh data'
104      ENDIF
105!jc: stop below should rather be a warning
106      IF( ln_apr_obc .AND. .NOT.ln_apr_dyn   )   &
107            CALL ctl_warn( 'sbc_apr: use inverse barometer ssh at open boundary ONLY requires ln_apr_dyn=T' )
108      !
109   END SUBROUTINE sbc_apr_init
110
111   SUBROUTINE sbc_apr( kt )
112      !!---------------------------------------------------------------------
113      !!                     ***  ROUTINE sbc_apr  ***
114      !!
115      !! ** Purpose :   read atmospheric pressure fields in netcdf files.
116      !!
117      !! ** Method  : - Read namelist namsbc_apr
118      !!              - Read Patm fields in netcdf files
119      !!              - Compute reference atmospheric pressure
120      !!              - Compute inverse barometer ssh
121      !! ** action  :   apr      : atmospheric pressure at kt
122      !!                ssh_ib   : inverse barometer ssh at kt
123      !!---------------------------------------------------------------------
124      INTEGER, INTENT(in)::   kt   ! ocean time step
125      !
126      !!----------------------------------------------------------------------
127
128      !                                         ! ========================== !
129      IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN      !    At each sbc time-step   !
130         !                                      ! ===========+++============ !
131         !
132         IF( kt /= nit000 )   ssh_ibb(:,:) = ssh_ib(:,:)    !* Swap of ssh_ib fields
133         !
134         CALL fld_read( kt, nn_fsbc, sf_apr )               !* input Patm provided at kt + nn_fsbc/2
135         !
136         !                                                  !* update the reference atmospheric pressure (if necessary)
137         IF( ln_ref_apr )   rn_pref = glob_sum( 'sbcapr', sf_apr(1)%fnow(:,:,1) * e1e2t(:,:) ) / tarea
138         !
139         !                                                  !* Patm related forcing at kt
140         ssh_ib(:,:) = - ( sf_apr(1)%fnow(:,:,1) - rn_pref ) * r1_grau    ! equivalent ssh (inverse barometer)
141         apr   (:,:) =     sf_apr(1)%fnow(:,:,1)                        ! atmospheric pressure
142         !
143         CALL iom_put( "ssh_ib", ssh_ib )                   !* output the inverse barometer ssh
144      ENDIF
145
146      !                                         ! ---------------------------------------- !
147      IF( kt == nit000 ) THEN                   !   set the forcing field at nit000 - 1    !
148         !                                      ! ---------------------------------------- !
149         !                                            !* Restart: read in restart file
150         IF( ln_rstart .AND. .NOT.l_1st_euler ) THEN
151            IF(lwp) WRITE(numout,*) 'sbc_apr:   ssh_ibb read in the restart file'
152            CALL iom_get( numror, jpdom_auto, 'ssh_ibb', ssh_ibb )   ! before inv. barometer ssh
153            !
154         ELSE                                         !* no restart: set from nit000 values
155            IF(lwp) WRITE(numout,*) 'sbc_apr:   ssh_ibb set to nit000 values'
156            ssh_ibb(:,:) = ssh_ib(:,:)
157         ENDIF
158      ENDIF
159      !                                         ! ---------------------------------------- !
160      IF( lrst_oce ) THEN                       !      Write in the ocean restart file     !
161         !                                      ! ---------------------------------------- !
162         IF(lwp) WRITE(numout,*)
163         IF(lwp) WRITE(numout,*) 'sbc_apr : ssh_ib written in ocean restart file at it= ', kt,' date= ', ndastp
164         IF(lwp) WRITE(numout,*) '~~~~'
165         CALL iom_rstput( kt, nitrst, numrow, 'ssh_ibb' , ssh_ib )
166      ENDIF
167      !
168   END SUBROUTINE sbc_apr
169
170   !!======================================================================
171END MODULE sbcapr
Note: See TracBrowser for help on using the repository browser.