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/2017/dev_r8600_xios_read_write/NEMOGCM/NEMO/OPA_SRC/SBC – NEMO

source: branches/2017/dev_r8600_xios_read_write/NEMOGCM/NEMO/OPA_SRC/SBC/sbcapr.F90 @ 8770

Last change on this file since 8770 was 8770, checked in by andmirek, 6 years ago

#1953 and #1962 merged (and some modifications) with write branch

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