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/2012/dev_LOCEAN_2012/NEMOGCM/NEMO/OPA_SRC/SBC – NEMO

source: branches/2012/dev_LOCEAN_2012/NEMOGCM/NEMO/OPA_SRC/SBC/sbcapr.F90 @ 3648

Last change on this file since 3648 was 3648, checked in by smasson, 11 years ago

enable "mini restart", see ticket:1019

File size: 9.3 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 obc_par         ! open boundary condition parameters
13   USE dom_oce         ! ocean space and time domain
14   USE sbc_oce         ! surface boundary condition
15   USE dynspg_oce      ! surface pressure gradient variables
16   USE phycst          ! physical constants
17   USE fldread         ! read input fields
18   USE in_out_manager  ! I/O manager
19   USE lib_fortran     ! distribued memory computing library
20   USE iom             ! IOM library
21   USE lib_mpp         ! MPP library
22
23   IMPLICIT NONE
24   PRIVATE
25
26   PUBLIC   sbc_apr    ! 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 = .FALSE.  !: ref. pressure: global mean Patm (F) or a constant (F)
31
32   REAL(wp), ALLOCATABLE, SAVE, PUBLIC, DIMENSION(:,:) ::   ssh_ib    ! Inverse barometer now    sea surface height   [m]
33   REAL(wp), ALLOCATABLE, SAVE, PUBLIC, DIMENSION(:,:) ::   ssh_ibb   ! Inverse barometer before sea surface height   [m]
34   REAL(wp), ALLOCATABLE, SAVE, PUBLIC, DIMENSION(:,:) ::   apr       ! atmospheric pressure at kt                 [N/m2]
35   
36   REAL(wp) ::   rpref = 101000._wp   ! reference atmospheric pressure          [N/m2]
37   REAL(wp) ::   tarea                ! whole domain mean masked ocean surface
38   REAL(wp) ::   r1_grau              ! = 1.e0 / (grav * rau0)
39   
40   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_apr   ! structure of input fields (file informations, fields read)
41
42   !! * Substitutions
43#  include "domzgr_substitute.h90"
44   !!----------------------------------------------------------------------
45   !! NEMO/OPA 4.0 , NEMO Consortium (2011)
46   !! $Id: $
47   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
48   !!----------------------------------------------------------------------
49CONTAINS
50
51   SUBROUTINE sbc_apr( kt )
52      !!---------------------------------------------------------------------
53      !!                     ***  ROUTINE sbc_apr  ***
54      !!
55      !! ** Purpose :   read atmospheric pressure fields in netcdf files.
56      !!
57      !! ** Method  : - Read namelist namsbc_apr
58      !!              - Read Patm fields in netcdf files
59      !!              - Compute reference atmospheric pressure
60      !!              - Compute inverse barometer ssh
61      !! ** action  :   apr      : atmospheric pressure at kt
62      !!                ssh_ib   : inverse barometer ssh at kt
63      !!---------------------------------------------------------------------
64      INTEGER, INTENT(in)::   kt   ! ocean time step
65      !!
66      INTEGER            ::   ierror  ! local integer
67      REAL(wp)           ::   zpref   ! local scalar
68      !!
69      CHARACTER(len=100) ::  cn_dir   ! Root directory for location of ssr files
70      TYPE(FLD_N)        ::  sn_apr   ! informations about the fields to be read
71      !!
72      NAMELIST/namsbc_apr/ cn_dir, sn_apr, ln_ref_apr
73      !!----------------------------------------------------------------------
74      !
75      !
76      !                                         ! -------------------- !
77      IF( kt == nit000 ) THEN                   ! First call kt=nit000 !
78         !                                      ! -------------------- !
79         !                                            !* set file information (default values)
80         ! ... default values (NB: frequency positive => hours, negative => months)
81         !            !   file   ! frequency !  variable  ! time intep !  clim   ! 'yearly' or ! weights  ! rotation !
82         !            !   name   !  (hours)  !   name     !   (T/F)    !  (T/F)  !  'monthly'  ! filename ! pairs    !
83         sn_apr = FLD_N( 'patm'  ,    24     ,  'patm'    ,  .false.   , .true.  ,   'yearly'  , ''       , ''       )
84         cn_dir  = './'          ! directory in which the Patm data are
85
86         REWIND( numnam )                             !* read in namlist namsbc_apr
87         READ  ( numnam, namsbc_apr ) 
88         !
89         ALLOCATE( sf_apr(1), STAT=ierror )           !* allocate and fill sf_sst (forcing structure) with sn_sst
90         IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'sbc_apr: unable to allocate sf_apr structure' )
91         !
92         CALL fld_fill( sf_apr, (/ sn_apr /), cn_dir, 'sbc_apr', 'Atmospheric pressure ', 'namsbc_apr' )
93                                ALLOCATE( sf_apr(1)%fnow(jpi,jpj,1)   )
94         IF( sn_apr%ln_tint )   ALLOCATE( sf_apr(1)%fdta(jpi,jpj,1,2) )
95                                ALLOCATE( ssh_ib(jpi,jpj) , ssh_ibb(jpi,jpj) )
96                                ALLOCATE( apr (jpi,jpj) )
97         !
98         IF(lwp) THEN                                 !* control print
99            WRITE(numout,*)
100            WRITE(numout,*) '   Namelist namsbc_apr : Atmospheric PRessure as extrenal forcing'
101            WRITE(numout,*) '      ref. pressure: global mean Patm (T) or a constant (F)  ln_ref_apr = ', ln_ref_apr
102         ENDIF
103         !
104         IF( ln_ref_apr ) THEN                        !* Compute whole inner domain mean masked ocean surface
105            tarea = glob_sum( e1t(:,:) * e2t(:,:) )
106            IF(lwp) WRITE(numout,*) '         Variable ref. Patm computed over a ocean surface of ', tarea*1e-6, 'km2'
107         ELSE
108            IF(lwp) WRITE(numout,*) '         Reference Patm used : ', rpref, ' N/m2'
109         ENDIF
110         !
111         r1_grau = 1.e0 / (grav * rau0)               !* constant for optimization
112         !
113         !                                            !* control check
114         IF( ln_apr_obc  )   &
115            CALL ctl_stop( 'sbc_apr: inverse barometer added to OBC ssh data not yet implemented ' )
116         IF( ln_apr_obc .AND. .NOT. lk_obc )   &
117            CALL ctl_stop( 'sbc_apr: add inverse barometer to OBC requires to use key_obc' )
118         IF( ( ln_apr_obc ) .AND. .NOT. lk_dynspg_ts )   &
119            CALL ctl_stop( 'sbc_apr: use inverse barometer ssh at open boundary ONLY possible with time-splitting' )
120         IF( ( ln_apr_obc ) .AND. .NOT. ln_apr_dyn   )   &
121            CALL ctl_stop( 'sbc_apr: use inverse barometer ssh at open boundary ONLY requires ln_apr_dyn=T' )
122      ENDIF
123
124      !                                         ! ========================== !
125      IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN      !    At each sbc time-step   !
126         !                                      ! ===========+++============ !
127         !
128         IF( kt /= nit000 )   ssh_ibb(:,:) = ssh_ib(:,:)    !* Swap of ssh_ib fields
129         !
130         CALL fld_read( kt, nn_fsbc, sf_apr )               !* input Patm provided at kt + nn_fsbc/2
131         !
132         !                                                  !* update the reference atmospheric pressure (if necessary)
133         IF( ln_ref_apr )   rpref = glob_sum( sf_apr(1)%fnow(:,:,1) * e1t(:,:) * e2t(:,:) ) / tarea
134         !
135         !                                                  !* Patm related forcing at kt
136         ssh_ib(:,:) = - ( sf_apr(1)%fnow(:,:,1) - rpref ) * r1_grau    ! equivalent ssh (inverse barometer)
137         apr   (:,:) =     sf_apr(1)%fnow(:,:,1)                        ! atmospheric pressure
138         !
139         CALL iom_put( "ssh_ib", ssh_ib )                   !* output the inverse barometer ssh
140      ENDIF
141
142      !                                         ! ---------------------------------------- !
143      IF( kt == nit000 ) THEN                   !   set the forcing field at nit000 - 1    !
144         !                                      ! ---------------------------------------- !
145         !                                            !* Restart: read in restart file
146         IF( ln_rstart .AND. iom_varid( numror, 'ssh_ibb', ldstop = .FALSE. ) > 0 ) THEN
147            IF(lwp) WRITE(numout,*) 'sbc_apr:   ssh_ibb read in the restart file'
148            CALL iom_get( numror, jpdom_autoglo, 'ssh_ibb', ssh_ibb )   ! before inv. barometer ssh
149            !
150         ELSE                                         !* no restart: set from nit000 values
151            IF(lwp) WRITE(numout,*) 'sbc_apr:   ssh_ibb set to nit000 values'
152            ssh_ibb(:,:) = ssh_ib(:,:)
153         ENDIF
154      ENDIF
155      !                                         ! ---------------------------------------- !
156      IF( lrst_oce ) THEN                       !      Write in the ocean restart file     !
157         !                                      ! ---------------------------------------- !
158         IF(lwp) WRITE(numout,*)
159         IF(lwp) WRITE(numout,*) 'sbc_apr : ssh_ib written in ocean restart file at it= ', kt,' date= ', ndastp
160         IF(lwp) WRITE(numout,*) '~~~~'
161         CALL iom_rstput( kt, nitrst, numrow, 'ssh_ibb' , ssh_ib )
162      ENDIF
163      !
164   END SUBROUTINE sbc_apr
165     
166   !!======================================================================
167END MODULE sbcapr
Note: See TracBrowser for help on using the repository browser.