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_v3.6_asm_nemovar_community/NEMOGCM/NEMO/OPA_SRC/ASM – NEMO

source: branches/UKMO/dev_r5518_v3.6_asm_nemovar_community/NEMOGCM/NEMO/OPA_SRC/ASM/asmbal.F90

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

Merge in revisions 6625:7726 of dev_r5518_v3.4_asm_nemovar_community, so this branch will be identical to revison 7726 of dev_r5518_v3.6_asm_nemovar_community.

File size: 6.0 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_fabm
19   USE par_fabm
20#elif defined key_medusa && defined key_foam_medusa
21   USE par_medusa
22#elif defined key_hadocc
23   USE par_hadocc
24#endif
25
26   IMPLICIT NONE
27
28   !! * Routine accessibility
29   PRIVATE
30   PUBLIC asm_bal_wri   !: Write out the background state
31
32CONTAINS
33
34   SUBROUTINE asm_bal_wri( kt )
35      !!-----------------------------------------------------------------------
36      !!
37      !!                  ***  ROUTINE asm_bal_wri ***
38      !!
39      !! ** Purpose : Write to file the balancing increments
40      !!              calculated for biogeochemistry
41      !!
42      !! ** Method  : Write to file the balancing increments
43      !!              calculated for biogeochemistry
44      !!
45      !! ** Action  :
46      !!                   
47      !! References :
48      !!
49      !! History    :
50      !!        ! 2014-08 (D. Ford)  Initial version, based on asm_bkg_wri
51      !!-----------------------------------------------------------------------
52      !! * Arguments
53      INTEGER, INTENT( IN ) :: kt        ! Current time-step
54      !! * Local declarations
55      CHARACTER(LEN=50) :: cl_asmbal     ! Filename (with extension)
56      LOGICAL           :: llok          ! Check if file exists
57      INTEGER           :: inum          ! File unit number
58      REAL(wp)          :: zdate         ! Date
59      !!-----------------------------------------------------------------------
60     
61      ! Set things up
62      zdate = REAL( ndastp )
63      WRITE(cl_asmbal, FMT='(A,".nc")' ) TRIM( c_asmbal )
64
65      ! Check if file exists
66      INQUIRE( FILE = TRIM( cl_asmbal ), EXIST = llok )
67      IF( .NOT. llok ) THEN
68         IF(lwp) WRITE(numout,*) ' Setting up assimilation balancing increments file '// &
69            &                    TRIM( c_asmbal ) // ' at timestep = ', kt
70
71         ! Define the output file       
72         CALL iom_open( c_asmbal, inum, ldwrt = .TRUE., kiolib = jprstlib)
73
74         ! Write the information
75         CALL iom_rstput( kt, kt, inum, 'rdastp' , zdate   )
76
77         IF ( ln_logchltotinc .OR. ln_logchlpftinc ) THEN
78#if defined key_fabm
79            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_chl1', logchl_balinc(:,:,:,jp_fabm_m1+jp_fabm_chl1) )
80            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_chl2', logchl_balinc(:,:,:,jp_fabm_m1+jp_fabm_chl2) )
81            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_chl3', logchl_balinc(:,:,:,jp_fabm_m1+jp_fabm_chl3) )
82            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_chl4', logchl_balinc(:,:,:,jp_fabm_m1+jp_fabm_chl4) )
83#elif defined key_medusa && defined key_foam_medusa
84            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_chn', logchl_balinc(:,:,:,jpchn) )
85            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_chd', logchl_balinc(:,:,:,jpchd) )
86            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_phn', logchl_balinc(:,:,:,jpphn) )
87            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_phd', logchl_balinc(:,:,:,jpphd) )
88            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_pds', logchl_balinc(:,:,:,jppds) )
89            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_zmi', logchl_balinc(:,:,:,jpzmi) )
90            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_zme', logchl_balinc(:,:,:,jpzme) )
91            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_din', logchl_balinc(:,:,:,jpdin) )
92            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_sil', logchl_balinc(:,:,:,jpsil) )
93            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_fer', logchl_balinc(:,:,:,jpfer) )
94            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_det', logchl_balinc(:,:,:,jpdet) )
95            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_dtc', logchl_balinc(:,:,:,jpdtc) )
96            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_dic', logchl_balinc(:,:,:,jpdic) )
97            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_alk', logchl_balinc(:,:,:,jpalk) )
98            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_oxy', logchl_balinc(:,:,:,jpoxy) )
99#elif defined key_hadocc
100            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_nut', logchl_balinc(:,:,:,jp_had_nut) )
101            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_phy', logchl_balinc(:,:,:,jp_had_phy) )
102            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_zoo', logchl_balinc(:,:,:,jp_had_zoo) )
103            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_det', logchl_balinc(:,:,:,jp_had_det) )
104            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_dic', logchl_balinc(:,:,:,jp_had_dic) )
105            CALL iom_rstput( kt, kt, inum, 'logchl_balinc_alk', logchl_balinc(:,:,:,jp_had_alk) )
106#endif
107         ENDIF
108
109         CALL iom_close( inum )
110      ELSE
111         CALL ctl_warn( TRIM( cl_asmbal ) // ' already exists ', &
112            &           ' Therefore not writing out balancing increments at this timestep', &
113            &           ' Something has probably gone wrong somewhere' )
114         IF(lwp) WRITE(numout,*) ' Failed to set up assimilation balancing increments file '// &
115            &                    TRIM( c_asmbal ) // ' at timestep = ', kt
116      ENDIF
117                                 
118   END SUBROUTINE asm_bal_wri
119END MODULE asmbal
Note: See TracBrowser for help on using the repository browser.