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.
asmbal.F90 in branches/UKMO/dev_r5518_GO6_package_asm_surf_bgc/NEMOGCM/NEMO/OPA_SRC/ASM – NEMO

source: branches/UKMO/dev_r5518_GO6_package_asm_surf_bgc/NEMOGCM/NEMO/OPA_SRC/ASM/asmbal.F90 @ 8428

Last change on this file since 8428 was 8428, checked in by dford, 7 years ago

Add logchl assimilation, with nitrogen balancing for HadOCC.

File size: 5.6 KB
RevLine 
[6983]1MODULE asmbal
2   !!======================================================================
3   !!                       ***  MODULE asmbal  ***
4   !! Assimilation balancing interface: Write to file the balancing increments
5   !!                                   calculated for biogeochemistry
6   !!======================================================================
7   !!----------------------------------------------------------------------
8   !!   'key_asminc' : Switch on the assimilation increment interface
9   !!----------------------------------------------------------------------
10   !!   asm_bal_wri  : Write out the background state
11   !!----------------------------------------------------------------------
12   !! * Modules used
13   USE par_kind, ONLY: &   ! Precision variables
14      & wp
15   USE iom                 ! I/O module
16   USE asminc              ! Main assimilation increments module
17   USE asmpar              ! Parameters for the assimilation interface
[8428]18#if defined key_medusa && defined key_foam_medusa
[7718]19   USE par_medusa
20#elif defined key_hadocc
21   USE par_hadocc
22#endif
[6983]23
24   IMPLICIT NONE
25
26   !! * Routine accessibility
27   PRIVATE
28   PUBLIC asm_bal_wri   !: Write out the background state
29
30CONTAINS
31
32   SUBROUTINE asm_bal_wri( kt )
33      !!-----------------------------------------------------------------------
34      !!
35      !!                  ***  ROUTINE asm_bal_wri ***
36      !!
37      !! ** Purpose : Write to file the balancing increments
38      !!              calculated for biogeochemistry
39      !!
40      !! ** Method  : Write to file the balancing increments
41      !!              calculated for biogeochemistry
42      !!
43      !! ** Action  :
44      !!                   
45      !! References :
46      !!
47      !! History    :
48      !!        ! 2014-08 (D. Ford)  Initial version, based on asm_bkg_wri
49      !!-----------------------------------------------------------------------
50      !! * Arguments
51      INTEGER, INTENT( IN ) :: kt        ! Current time-step
52      !! * Local declarations
53      CHARACTER(LEN=50) :: cl_asmbal     ! Filename (with extension)
54      LOGICAL           :: llok          ! Check if file exists
55      INTEGER           :: inum          ! File unit number
56      REAL(wp)          :: zdate         ! Date
57      !!-----------------------------------------------------------------------
58     
59      ! Set things up
60      zdate = REAL( ndastp )
61      WRITE(cl_asmbal, FMT='(A,".nc")' ) TRIM( c_asmbal )
62
63      ! Check if file exists
64      INQUIRE( FILE = TRIM( cl_asmbal ), EXIST = llok )
65      IF( .NOT. llok ) THEN
66         IF(lwp) WRITE(numout,*) ' Setting up assimilation balancing increments file '// &
67            &                    TRIM( c_asmbal ) // ' at timestep = ', kt
68
69         ! Define the output file       
70         CALL iom_open( c_asmbal, inum, ldwrt = .TRUE., kiolib = jprstlib)
71
72         ! Write the information
73         CALL iom_rstput( kt, kt, inum, 'rdastp' , zdate   )
74
[8428]75         IF ( ln_logchlinc ) THEN
76#if defined key_medusa && defined key_foam_medusa
[7716]77            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_chn', logchl_balinc(:,:,:,jpchn) )
78            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_chd', logchl_balinc(:,:,:,jpchd) )
[8428]79            IF ( ln_logchlbal ) THEN
80               CALL iom_rstput( kt, kt, inum, 'logchl_balinc_phn', logchl_balinc(:,:,:,jpphn) )
81               CALL iom_rstput( kt, kt, inum, 'logchl_balinc_phd', logchl_balinc(:,:,:,jpphd) )
82               CALL iom_rstput( kt, kt, inum, 'logchl_balinc_pds', logchl_balinc(:,:,:,jppds) )
83               CALL iom_rstput( kt, kt, inum, 'logchl_balinc_zmi', logchl_balinc(:,:,:,jpzmi) )
84               CALL iom_rstput( kt, kt, inum, 'logchl_balinc_zme', logchl_balinc(:,:,:,jpzme) )
85               CALL iom_rstput( kt, kt, inum, 'logchl_balinc_din', logchl_balinc(:,:,:,jpdin) )
86               CALL iom_rstput( kt, kt, inum, 'logchl_balinc_sil', logchl_balinc(:,:,:,jpsil) )
87               CALL iom_rstput( kt, kt, inum, 'logchl_balinc_fer', logchl_balinc(:,:,:,jpfer) )
88               CALL iom_rstput( kt, kt, inum, 'logchl_balinc_det', logchl_balinc(:,:,:,jpdet) )
89               CALL iom_rstput( kt, kt, inum, 'logchl_balinc_dtc', logchl_balinc(:,:,:,jpdtc) )
90               CALL iom_rstput( kt, kt, inum, 'logchl_balinc_dic', logchl_balinc(:,:,:,jpdic) )
91               CALL iom_rstput( kt, kt, inum, 'logchl_balinc_alk', logchl_balinc(:,:,:,jpalk) )
92               CALL iom_rstput( kt, kt, inum, 'logchl_balinc_oxy', logchl_balinc(:,:,:,jpoxy) )
93            ENDIF
[6983]94#elif defined key_hadocc
[7716]95            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_phy', logchl_balinc(:,:,:,jp_had_phy) )
[8428]96            IF ( ln_logchlbal ) THEN
97               CALL iom_rstput( kt, kt, inum, 'logchl_balinc_nut', logchl_balinc(:,:,:,jp_had_nut) )
98               CALL iom_rstput( kt, kt, inum, 'logchl_balinc_zoo', logchl_balinc(:,:,:,jp_had_zoo) )
99               CALL iom_rstput( kt, kt, inum, 'logchl_balinc_det', logchl_balinc(:,:,:,jp_had_pdn) )
100               CALL iom_rstput( kt, kt, inum, 'logchl_balinc_dic', logchl_balinc(:,:,:,jp_had_dic) )
101               CALL iom_rstput( kt, kt, inum, 'logchl_balinc_alk', logchl_balinc(:,:,:,jp_had_alk) )
102            ENDIF
[6983]103#endif
104         ENDIF
105
106         CALL iom_close( inum )
107      ELSE
108         CALL ctl_warn( TRIM( cl_asmbal ) // ' already exists ', &
109            &           ' Therefore not writing out balancing increments at this timestep', &
110            &           ' Something has probably gone wrong somewhere' )
111         IF(lwp) WRITE(numout,*) ' Failed to set up assimilation balancing increments file '// &
112            &                    TRIM( c_asmbal ) // ' at timestep = ', kt
113      ENDIF
114                                 
115   END SUBROUTINE asm_bal_wri
116END MODULE asmbal
Note: See TracBrowser for help on using the repository browser.