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 @ 8456

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

Add pCO2/fCO2 assimilation.

File size: 6.5 KB
Line 
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
18#if defined key_medusa && defined key_foam_medusa
19   USE par_medusa
20#elif defined key_hadocc
21   USE par_hadocc
22#endif
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
75         IF ( ln_logchlinc ) THEN
76#if defined key_medusa
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) )
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
94#elif defined key_hadocc
95            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_phy', logchl_balinc(:,:,:,jp_had_phy) )
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
103#endif
104         ENDIF
105
106         IF ( ln_pco2inc ) THEN
107#if defined key_medusa
108            CALL iom_rstput( kt, kt, inum, 'pco2_balinc_dic', pco2_balinc(:,:,:,jpdic) )
109            CALL iom_rstput( kt, kt, inum, 'pco2_balinc_alk', pco2_balinc(:,:,:,jpalk) )
110#elif defined key_hadocc
111            CALL iom_rstput( kt, kt, inum, 'pco2_balinc_dic', pco2_balinc(:,:,:,jp_had_dic) )
112            CALL iom_rstput( kt, kt, inum, 'pco2_balinc_alk', pco2_balinc(:,:,:,jp_had_alk) )
113#endif
114         ELSE IF ( ln_fco2inc ) THEN
115#if defined key_medusa
116            CALL iom_rstput( kt, kt, inum, 'fco2_balinc_dic', pco2_balinc(:,:,:,jpdic) )
117            CALL iom_rstput( kt, kt, inum, 'fco2_balinc_alk', pco2_balinc(:,:,:,jpalk) )
118#elif defined key_hadocc
119            CALL iom_rstput( kt, kt, inum, 'fco2_balinc_dic', pco2_balinc(:,:,:,jp_had_dic) )
120            CALL iom_rstput( kt, kt, inum, 'fco2_balinc_alk', pco2_balinc(:,:,:,jp_had_alk) )
121#endif
122         ENDIF
123
124         CALL iom_close( inum )
125      ELSE
126         CALL ctl_warn( TRIM( cl_asmbal ) // ' already exists ', &
127            &           ' Therefore not writing out balancing increments at this timestep', &
128            &           ' Something has probably gone wrong somewhere' )
129         IF(lwp) WRITE(numout,*) ' Failed to set up assimilation balancing increments file '// &
130            &                    TRIM( c_asmbal ) // ' at timestep = ', kt
131      ENDIF
132                                 
133   END SUBROUTINE asm_bal_wri
134END MODULE asmbal
Note: See TracBrowser for help on using the repository browser.