source: branches/UKMO/AMM15_v3_6_STABLE_package_collate_bgc_diagnostics/NEMOGCM/NEMO/TOP_SRC/FABM/trcini_fabm.F90 @ 10366

Last change on this file since 10366 was 10366, checked in by dford, 23 months ago

Remove visibility, as now available through FABM, and switch from deprecated get_bulk to get_interior.

File size: 23.1 KB
Line 
1MODULE trcini_fabm
2   !!======================================================================
3   !!                         ***  MODULE trcini_fabm  ***
4   !! TOP :   initialisation of the FABM tracers
5   !!======================================================================
6   !! History :   2.0  !  2007-12  (C. Ethe, G. Madec) Original code
7   !!----------------------------------------------------------------------
8#if defined key_fabm
9   !!----------------------------------------------------------------------
10   !!   'key_fabm'                                               FABM tracers
11   !!----------------------------------------------------------------------
12   !! trc_ini_fabm   : FABM model initialisation
13   !!----------------------------------------------------------------------
14   USE par_trc         ! TOP parameters
15   USE oce_trc
16   USE trc
17   USE par_fabm
18   USE trcsms_fabm
19   USE fabm_config,ONLY: fabm_create_model_from_yaml_file
20   USE fabm,ONLY: type_external_variable, fabm_initialize_library
21   USE inputs_fabm,ONLY: initialize_inputs,link_inputs, &
22     type_input_variable,type_input_data,type_river_data, &
23     first_input_data,first_river_data
24#if defined key_git_version
25   USE fabm_version,ONLY: fabm_commit_id=>git_commit_id, &
26                          fabm_branch_name=>git_branch_name
27   USE fabm_types,ONLY: type_version,first_module_version
28#endif
29
30
31   IMPLICIT NONE
32   PRIVATE
33
34#if defined key_git_version
35!#include "gitversion.h90"
36   CHARACTER(len=*),parameter :: git_commit_id = _NEMO_COMMIT_ID_
37   CHARACTER(len=*),parameter :: git_branch_name = _NEMO_BRANCH_
38#endif
39
40   PUBLIC   trc_ini_fabm   ! called by trcini.F90 module
41   PUBLIC   nemo_fabm_init
42
43   !!----------------------------------------------------------------------
44   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
45   !! $Id$
46   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
47   !!----------------------------------------------------------------------
48CONTAINS
49
50   SUBROUTINE nemo_fabm_init()
51      INTEGER :: jn
52      INTEGER, PARAMETER :: xml_unit = 1979
53      TYPE (type_input_data),POINTER :: input_data
54      TYPE (type_river_data),POINTER :: river_data
55      CLASS (type_input_variable),POINTER :: input_pointer
56
57      ! Allow FABM to parse fabm.yaml. This ensures numbers of variables are known.
58      call fabm_create_model_from_yaml_file(model)
59
60      jp_fabm = size(model%state_variables)
61      jp_fabm_bottom = size(model%bottom_state_variables)
62      jp_fabm_surface = size(model%surface_state_variables)
63      jp_fabm0 = jptra + 1
64      jp_fabm1 = jptra + jp_fabm
65      jp_fabm_m1=jptra
66      jptra = jptra + jp_fabm
67      jp_fabm_2d = size(model%horizontal_diagnostic_variables)
68      jp_fabm_3d = size(model%diagnostic_variables)
69      jpdia2d = jpdia2d + jp_fabm_2d
70      jpdia3d = jpdia3d + jp_fabm_3d
71      jpdiabio = jpdiabio + jp_fabm
72
73      !Initialize input data structures.
74      call initialize_inputs
75
76      ! Get indexes for select state variables
77      jp_fabm_chl1 = fabm_state_index( 'P1_Chl' )
78      jp_fabm_chl2 = fabm_state_index( 'P2_Chl' )
79      jp_fabm_chl3 = fabm_state_index( 'P3_Chl' )
80      jp_fabm_chl4 = fabm_state_index( 'P4_Chl' )
81      jp_fabm_p1c  = fabm_state_index( 'P1_c' )
82      jp_fabm_p1n  = fabm_state_index( 'P1_n' )
83      jp_fabm_p1p  = fabm_state_index( 'P1_p' )
84      jp_fabm_p1s  = fabm_state_index( 'P1_s' )
85      jp_fabm_p2c  = fabm_state_index( 'P2_c' )
86      jp_fabm_p2n  = fabm_state_index( 'P2_n' )
87      jp_fabm_p2p  = fabm_state_index( 'P2_p' )
88      jp_fabm_p3c  = fabm_state_index( 'P3_c' )
89      jp_fabm_p3n  = fabm_state_index( 'P3_n' )
90      jp_fabm_p3p  = fabm_state_index( 'P3_p' )
91      jp_fabm_p4c  = fabm_state_index( 'P4_c' )
92      jp_fabm_p4n  = fabm_state_index( 'P4_n' )
93      jp_fabm_p4p  = fabm_state_index( 'P4_p' )
94      jp_fabm_z4c  = fabm_state_index( 'Z4_c' )
95      jp_fabm_z5c  = fabm_state_index( 'Z5_c' )
96      jp_fabm_z5n  = fabm_state_index( 'Z5_n' )
97      jp_fabm_z5p  = fabm_state_index( 'Z5_p' )
98      jp_fabm_z6c  = fabm_state_index( 'Z6_c' )
99      jp_fabm_z6n  = fabm_state_index( 'Z6_n' )
100      jp_fabm_z6p  = fabm_state_index( 'Z6_p' )
101      jp_fabm_n1p  = fabm_state_index( 'N1_p' )
102      jp_fabm_n3n  = fabm_state_index( 'N3_n' )
103      jp_fabm_n4n  = fabm_state_index( 'N4_n' )
104      jp_fabm_n5s  = fabm_state_index( 'N5_s' )
105      jp_fabm_o2o  = fabm_state_index( 'O2_o' )
106      jp_fabm_o3c  = fabm_state_index( 'O3_c' )
107      jp_fabm_o3a  = fabm_state_index( 'O3_bioalk' )
108
109      ! Get indexes for select diagnostic variables
110      jp_fabm_o3ph = fabm_diag_index( 'O3_pH' )
111      jp_fabm_o3pc = fabm_diag_index( 'O3_pCO2' )
112
113      IF (lwp) THEN
114         ! write field_def_fabm.xml on lead process
115         OPEN(UNIT=xml_unit,FILE='field_def_fabm.xml',ACTION='WRITE',STATUS='REPLACE')
116
117         WRITE (xml_unit,1000) '<field_definition level="1" prec="4" operation="average" enabled=".TRUE." default_value="1.e20" >'
118
119         WRITE (xml_unit,1000) ' <field_group id="ptrc_T" grid_ref="grid_T_3D">'
120         DO jn=1,jp_fabm
121            CALL write_variable_xml(xml_unit,model%state_variables(jn))
122#if defined key_trdtrc
123            CALL write_trends_xml(xml_unit,model%state_variables(jn))
124#endif
125            CALL write_25hourm_xml(xml_unit,model%state_variables(jn))
126            CALL write_tmb_xml(xml_unit,model%state_variables(jn))
127         END DO
128         WRITE (xml_unit,1000) ' </field_group>'
129
130         WRITE (xml_unit,1000) ' <field_group id="sf_T" grid_ref="grid_T_2D">'
131         DO jn=1,jp_fabm_surface
132            CALL write_variable_xml(xml_unit,model%surface_state_variables(jn))
133            CALL write_25hourm_xml(xml_unit,model%surface_state_variables(jn))
134         END DO
135         DO jn=1,jp_fabm_bottom
136            CALL write_variable_xml(xml_unit,model%bottom_state_variables(jn))
137            CALL write_25hourm_xml(xml_unit,model%bottom_state_variables(jn))
138         END DO
139         WRITE (xml_unit,1000) ' </field_group>'
140
141         WRITE (xml_unit,1000) ' <field_group id="diad_T" grid_ref="grid_T_2D">'
142         DO jn=1,size(model%diagnostic_variables)
143            CALL write_variable_xml(xml_unit,model%diagnostic_variables(jn),3)
144            CALL write_25hourm_xml(xml_unit,model%diagnostic_variables(jn),3)
145            CALL write_tmb_xml(xml_unit,model%diagnostic_variables(jn))
146         END DO
147         DO jn=1,size(model%horizontal_diagnostic_variables)
148            CALL write_variable_xml(xml_unit,model%horizontal_diagnostic_variables(jn))
149            CALL write_25hourm_xml(xml_unit,model%horizontal_diagnostic_variables(jn))
150         END DO
151         WRITE (xml_unit,1000) ' </field_group>'
152
153         WRITE (xml_unit,1000) ' <field_group id="fabm_scalar" grid_ref="grid_0">'
154         DO jn=1,size(model%conserved_quantities)
155            CALL write_variable_xml(xml_unit,model%conserved_quantities(jn))
156         END DO
157         WRITE (xml_unit,1000) ' </field_group>'
158
159         WRITE (xml_unit,1000) ' <field_group id="fabm_input" grid_ref="grid_T_2D">'
160         input_data => first_input_data
161         DO WHILE (ASSOCIATED(input_data))
162           input_pointer => input_data
163           CALL write_input_xml(xml_unit,input_pointer)
164            input_data => input_data%next
165         END DO
166         river_data => first_river_data
167         DO WHILE (ASSOCIATED(river_data))
168           input_pointer => river_data
169           CALL write_input_xml(xml_unit,input_pointer,3)
170            river_data => river_data%next
171         END DO
172         WRITE (xml_unit,1000) ' </field_group>'
173
174         WRITE (xml_unit,1000) '</field_definition>'
175
176         CLOSE(xml_unit)
177      END IF
178      IF( lk_mpp )   CALL mppsync !Ensure field_def_fabm is ready.
179
1801000 FORMAT (A)
181
182   END SUBROUTINE nemo_fabm_init
183
184   SUBROUTINE write_variable_xml(xml_unit,variable,flag_grid_ref)
185      INTEGER,INTENT(IN) :: xml_unit
186      INTEGER,INTENT(IN),OPTIONAL :: flag_grid_ref
187      CLASS (type_external_variable),INTENT(IN) :: variable
188
189      CHARACTER(LEN=20) :: missing_value,string_dimensions
190      INTEGER :: number_dimensions
191
192      ! Check variable dimension for grid_ref specificaiton.
193      ! Default is to not specify the grid_ref in the field definition.
194      IF (present(flag_grid_ref)) THEN
195          number_dimensions=flag_grid_ref
196      ELSE
197          number_dimensions=-1 !default, don't specify grid_ref
198      ENDIF
199
200      WRITE (missing_value,'(E9.3)') variable%missing_value
201      WRITE (string_dimensions,'(I1)') number_dimensions
202      SELECT CASE (number_dimensions)
203      CASE (3)
204         WRITE (xml_unit,'(A)') '  <field id="'//TRIM(variable%name)//'" long_name="'//TRIM(variable%long_name)//'" unit="'//TRIM(variable%units)//'" default_value="'//TRIM(ADJUSTL(missing_value))//'" grid_ref="grid_T_3D" />'
205      CASE (2)
206         WRITE (xml_unit,'(A)') '  <field id="'//TRIM(variable%name)//'" long_name="'//TRIM(variable%long_name)//'" unit="'//TRIM(variable%units)//'" default_value="'//TRIM(ADJUSTL(missing_value))//'" grid_ref="grid_T_2D"/>'
207      CASE (0)
208         WRITE (xml_unit,'(A)') '  <field id="'//TRIM(variable%name)//'" long_name="'//TRIM(variable%long_name)//'" unit="'//TRIM(variable%units)//'" default_value="'//TRIM(ADJUSTL(missing_value))//'" grid_ref="1point"/>'
209      CASE (-1)
210         WRITE (xml_unit,'(A)') '  <field id="'//TRIM(variable%name)//'" long_name="'//TRIM(variable%long_name)//'" unit="'//TRIM(variable%units)//'" default_value="'//TRIM(ADJUSTL(missing_value))//'" />'
211      CASE default
212         IF(lwp) WRITE(numout,*) ' trc_ini_fabm: Failing to initialise output of variable '//TRIM(variable%name)//': Output of '//TRIM(ADJUSTL(string_dimensions))//'-dimensional variables not supported!!!'
213      END SELECT
214
215   END SUBROUTINE write_variable_xml
216
217   SUBROUTINE write_25hourm_xml(xml_unit,variable,flag_grid_ref)
218      INTEGER,INTENT(IN) :: xml_unit
219      INTEGER,INTENT(IN),OPTIONAL :: flag_grid_ref
220      CLASS (type_external_variable),INTENT(IN) :: variable
221
222      CHARACTER(LEN=20) :: missing_value,string_dimensions
223      INTEGER :: number_dimensions
224
225      ! Check variable dimension for grid_ref specificaiton.
226      ! Default is to not specify the grid_ref in the field definition.
227      IF (present(flag_grid_ref)) THEN
228          number_dimensions=flag_grid_ref
229      ELSE
230          number_dimensions=-1 !default, don't specify grid_ref
231      ENDIF
232
233      WRITE (missing_value,'(E9.3)') 1.e+20
234      WRITE (string_dimensions,'(I1)') number_dimensions
235      SELECT CASE (number_dimensions)
236      CASE (3)
237         WRITE (xml_unit,'(A)') '  <field id="'//TRIM(variable%name)//'25h'//'" long_name="'//TRIM(variable%long_name)//' 25-hour mean'//'" unit="'//TRIM(variable%units)//'" default_value="'//TRIM(ADJUSTL(missing_value))//'" grid_ref="grid_T_3D" />'
238      CASE (2)
239         WRITE (xml_unit,'(A)') '  <field id="'//TRIM(variable%name)//'25h'//'" long_name="'//TRIM(variable%long_name)//' 25-hour mean'//'" unit="'//TRIM(variable%units)//'" default_value="'//TRIM(ADJUSTL(missing_value))//'" grid_ref="grid_T_2D"/>'
240      CASE (0)
241         WRITE (xml_unit,'(A)') '  <field id="'//TRIM(variable%name)//'25h'//'" long_name="'//TRIM(variable%long_name)//' 25-hour mean'//'" unit="'//TRIM(variable%units)//'" default_value="'//TRIM(ADJUSTL(missing_value))//'" grid_ref="1point"/>'
242      CASE (-1)
243         WRITE (xml_unit,'(A)') '  <field id="'//TRIM(variable%name)//'25h'//'" long_name="'//TRIM(variable%long_name)//' 25-hour mean'//'" unit="'//TRIM(variable%units)//'" default_value="'//TRIM(ADJUSTL(missing_value))//'" />'
244      CASE default
245         IF(lwp) WRITE(numout,*) ' trc_ini_fabm: Failing to initialise output of variable '//TRIM(variable%name)//'25h'//': Output of '//TRIM(ADJUSTL(string_dimensions))//'-dimensional variables not supported!!!'
246      END SELECT
247
248   END SUBROUTINE write_25hourm_xml
249
250   SUBROUTINE write_tmb_xml(xml_unit,variable)
251      INTEGER,INTENT(IN) :: xml_unit
252      CLASS (type_external_variable),INTENT(IN) :: variable
253
254      CHARACTER(LEN=20) :: missing_value
255
256      WRITE (missing_value,'(E9.3)') 1.e+20
257      WRITE (xml_unit,'(A)') '  <field id="top_'//TRIM(variable%name)//'" long_name="Top-level '//TRIM(variable%long_name)//'" unit="'//TRIM(variable%units)//'" default_value="'//TRIM(ADJUSTL(missing_value))//'" grid_ref="grid_T_2D"/>'
258      WRITE (xml_unit,'(A)') '  <field id="mid_'//TRIM(variable%name)//'" long_name="Middle-level '//TRIM(variable%long_name)//'" unit="'//TRIM(variable%units)//'" default_value="'//TRIM(ADJUSTL(missing_value))//'" grid_ref="grid_T_2D"/>'
259      WRITE (xml_unit,'(A)') '  <field id="bot_'//TRIM(variable%name)//'" long_name="Bottom-level '//TRIM(variable%long_name)//'" unit="'//TRIM(variable%units)//'" default_value="'//TRIM(ADJUSTL(missing_value))//'" grid_ref="grid_T_2D"/>'
260
261   END SUBROUTINE write_tmb_xml
262
263   SUBROUTINE write_trends_xml(xml_unit,variable,flag_grid_ref)
264      INTEGER,INTENT(IN) :: xml_unit
265      INTEGER,INTENT(IN),OPTIONAL :: flag_grid_ref
266      CLASS (type_external_variable),INTENT(IN) :: variable
267
268      INTEGER :: number_dimensions,i
269      CHARACTER(LEN=20) :: missing_value,string_dimensions
270#if defined key_tracer_budget
271      CHARACTER(LEN=3),DIMENSION(10),PARAMETER :: trd_tags = (/ &
272        'LDF','BBL','FOR','ZDF','DMP','SMS','ATF', &
273        'RDB','RDN','VMV' /)
274      CHARACTER(LEN=3),DIMENSION(3),PARAMETER :: trd_e3t_tags = (/ &
275        'XAD','YAD','ZAD' /)
276#else
277      CHARACTER(LEN=3),DIMENSION(13),PARAMETER :: trd_tags = (/ &
278        'XAD','YAD','ZAD','LDF','BBL','FOR','ZDF','DMP','SMS','ATF', &
279        'RDB','RDN','VMV' /)
280#endif
281
282      ! Check variable dimension for grid_ref specificaiton.
283      ! Default is to not specify the grid_ref in the field definition.
284      IF (present(flag_grid_ref)) THEN
285          number_dimensions=flag_grid_ref
286      ELSE
287          number_dimensions=-1 !default, don't specify grid_ref
288      ENDIF
289
290      WRITE (missing_value,'(E9.3)') -2.E20
291      WRITE (string_dimensions,'(I1)') number_dimensions
292      SELECT CASE (number_dimensions)
293      CASE (3)
294        DO i=1,size(trd_tags)
295         WRITE (xml_unit,'(A)') '  <field id="'//TRIM(trd_tags(i))//'_'//TRIM(variable%name)//'" long_name="'// &
296            &                   TRIM(variable%long_name)//' '//TRIM(trd_tags(i))//' trend" unit="'//            &
297            &                   TRIM(variable%units)//'/s" default_value="'//                                   &
298            &                   TRIM(ADJUSTL(missing_value))//'" grid_ref="grid_T_3D" />'
299        END DO
300#if defined key_tracer_budget
301        DO i=1,size(trd_e3t_tags)
302         WRITE (xml_unit,'(A)') '  <field id="'//TRIM(trd_e3t_tags(i))//'_'//TRIM(variable%name)//                     &
303            &                   '_e3t" long_name="'//TRIM(variable%long_name)//' cell depth integrated '//             &
304            &                   TRIM(trd_e3t_tags(i))//' trend" unit="'//TRIM(variable%units)//'/s" default_value="'// &
305            &                   TRIM(ADJUSTL(missing_value))//'" grid_ref="grid_T_3D" />'
306        END DO
307        WRITE (xml_unit,'(A)') '  <field id="'//TRIM(variable%name)//'_e3t" long_name="'//TRIM(variable%long_name)// &
308           &                   ' cell depth integrated" unit="'//TRIM(variable%units)//'/s" default_value="'//       &
309           &                   TRIM(ADJUSTL(missing_value))//'" grid_ref="grid_T_3D" />'
310#endif
311      CASE (-1)
312        DO i=1,size(trd_tags)
313         WRITE (xml_unit,'(A)') '  <field id="'//TRIM(trd_tags(i))//'_'//TRIM(variable%name)//'" long_name="'//   &
314            &                   TRIM(variable%long_name)//' '//TRIM(trd_tags(i))//' trend" unit="'//              &
315            &                   TRIM(variable%units)//'/s" default_value="'//TRIM(ADJUSTL(missing_value))//'" />'
316        END DO
317#if defined key_tracer_budget
318        DO i=1,size(trd_e3t_tags)
319         WRITE (xml_unit,'(A)') '  <field id="'//TRIM(trd_e3t_tags(i))//'_'//TRIM(variable%name)//                     &
320            &                   '_e3t" long_name="'//TRIM(variable%long_name)//' cell depth integrated '//             &
321            &                   TRIM(trd_e3t_tags(i))//' trend" unit="'//TRIM(variable%units)//'/s" default_value="'// &
322            &                   TRIM(ADJUSTL(missing_value))//'" />'
323        END DO
324        WRITE (xml_unit,'(A)') '  <field id="'//TRIM(variable%name)//'_e3t" long_name="'//TRIM(variable%long_name)// &
325           &                   ' cell depth integrated" unit="'//TRIM(variable%units)//'/s" default_value="'//       &
326           &                   TRIM(ADJUSTL(missing_value))//'" />'
327#endif
328      CASE default
329         IF(lwp) WRITE(numout,*) ' trc_ini_fabm: Failing to initialise trends of variable '//TRIM(variable%name)// &
330            &                    ': Output of '//TRIM(ADJUSTL(string_dimensions))//'-dimensional trends not supported!!!'
331      END SELECT
332
333   END SUBROUTINE write_trends_xml
334
335   SUBROUTINE write_input_xml(xml_unit,variable,flag_grid_ref)
336      INTEGER,INTENT(IN) :: xml_unit
337      INTEGER,INTENT(IN),OPTIONAL :: flag_grid_ref
338      CLASS(type_input_variable),POINTER,INTENT(IN) :: variable
339
340      INTEGER :: number_dimensions,i
341      CHARACTER(LEN=20) :: missing_value,string_dimensions
342
343      ! Check variable dimension for grid_ref specificaiton.
344      ! Default is to not specify the grid_ref in the field definition.
345      IF (present(flag_grid_ref)) THEN
346          number_dimensions=flag_grid_ref
347      ELSE
348          number_dimensions=-1 !default, don't specify grid_ref
349      ENDIF
350
351      WRITE (missing_value,'(E9.3)') -2.E20
352      WRITE (string_dimensions,'(I1)') number_dimensions
353      SELECT CASE (number_dimensions)
354      CASE (3)
355        WRITE (xml_unit,'(A)') '  <field id="'//'INP_'//TRIM(variable%sf(1)%clvar)//'" long_name="'//TRIM(variable%sf(1)%clvar)//' input" unit="" default_value="'//TRIM(ADJUSTL(missing_value))//'" grid_ref="grid_T_3D" />'
356      CASE (-1)
357        WRITE (xml_unit,'(A)') '  <field id="'//'INP_'//TRIM(variable%sf(1)%clvar)//'" long_name="'//TRIM(variable%sf(1)%clvar)//' input" unit="" default_value="'//TRIM(ADJUSTL(missing_value))//'" />'
358      CASE default
359         IF(lwp) WRITE(numout,*) ' trc_ini_fabm: Failing to initialise input diagnostic of variable '//TRIM(variable%sf(1)%clvar)//': Output of '//TRIM(ADJUSTL(string_dimensions))//'-dimensional diagnostic not supported!!!'
360      END SELECT
361
362   END SUBROUTINE write_input_xml
363
364   SUBROUTINE trc_ini_fabm
365      !!----------------------------------------------------------------------
366      !!                     ***  trc_ini_fabm  ***
367      !!
368      !! ** Purpose :   initialization for FABM model
369      !!
370      !! ** Method  : - Read the namcfc namelist and check the parameter values
371      !!----------------------------------------------------------------------
372#if defined key_git_version
373      TYPE (type_version),POINTER :: version
374#endif
375      INTEGER :: jn
376
377      !                       ! Allocate FABM arrays
378      IF( trc_sms_fabm_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'trc_ini_fabm: unable to allocate FABM arrays' )
379
380      IF(lwp) WRITE(numout,*)
381      IF(lwp) WRITE(numout,*) ' trc_ini_fabm: initialisation of FABM model'
382      IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~'
383#if defined key_git_version
384      IF(lwp) WRITE(numout,*) ' NEMO version:   ',git_commit_id,' (',git_branch_name,' branch)'
385      IF(lwp) WRITE(numout,*) ' FABM version:   ',fabm_commit_id,' (',fabm_branch_name,' branch)'
386#endif
387
388      call fabm_initialize_library()
389#if defined key_git_version
390      version => first_module_version
391
392      do while (associated(version))
393         IF(lwp) WRITE(numout,*)  ' '//trim(version%module_name)//' version:   ',trim(version%version_string)
394         version => version%next
395      end do
396#endif
397
398      ! Log mapping of FABM states:
399      IF (lwp) THEN
400         IF (jp_fabm.gt.0) WRITE(numout,*) " FABM tracers:"
401         DO jn=1,jp_fabm
402            WRITE(numout,*) "   State",jn,":",trim(model%state_variables(jn)%name), &
403               " (",trim(model%state_variables(jn)%long_name), &
404               ") [",trim(model%state_variables(jn)%units),"]"
405         ENDDO
406         IF (jp_fabm_surface.gt.0) WRITE(numout,*) "FABM seasurface states:"
407         DO jn=1,jp_fabm_surface
408            WRITE(numout,*) "   State",jn,":",trim(model%surface_state_variables(jn)%name), &
409               " (",trim(model%surface_state_variables(jn)%long_name), &
410               ") [",trim(model%surface_state_variables(jn)%units),"]"
411         ENDDO
412         IF (jp_fabm_bottom.gt.0) WRITE(numout,*) "FABM seafloor states:"
413         DO jn=1,jp_fabm_bottom
414            WRITE(numout,*) "   State",jn,":",trim(model%bottom_state_variables(jn)%name), &
415               " (",trim(model%bottom_state_variables(jn)%long_name), &
416               ") [",trim(model%bottom_state_variables(jn)%units),"]"
417         ENDDO
418      ENDIF
419
420   END SUBROUTINE trc_ini_fabm
421
422   INTEGER FUNCTION fabm_state_index( state_name )
423      !!----------------------------------------------------------------------
424      !!                     ***  fabm_state_index  *** 
425      !!
426      !! ** Purpose :   return index of a given FABM state variable
427      !!
428      !! ** Method  : - loop through state variables until found
429      !!----------------------------------------------------------------------
430     
431      IMPLICIT NONE
432     
433      CHARACTER(LEN=256), INTENT(IN) :: state_name
434     
435      INTEGER                        :: jn
436
437      !!----------------------------------------------------------------------
438     
439      fabm_state_index = -1
440      DO jn=1,jp_fabm
441         IF (TRIM(model%state_variables(jn)%name) == TRIM(state_name)) THEN
442            fabm_state_index = jn
443            EXIT
444         ENDIF
445      END DO
446      IF (fabm_state_index == -1) THEN
447         CALL ctl_stop( 'Could not find '//TRIM(state_name)//' state variable' )
448      ELSE
449         IF (lwp) WRITE(numout,*) 'Index for '//TRIM(state_name)//' is: ', fabm_state_index
450      ENDIF
451   
452   END FUNCTION fabm_state_index
453
454   INTEGER FUNCTION fabm_diag_index( diag_name )
455      !!----------------------------------------------------------------------
456      !!                     ***  fabm_state_index  *** 
457      !!
458      !! ** Purpose :   return index of a given FABM diagnostic variable
459      !!
460      !! ** Method  : - loop through diagnostic variables until found
461      !!----------------------------------------------------------------------
462     
463      IMPLICIT NONE
464     
465      CHARACTER(LEN=256), INTENT(IN) :: diag_name
466     
467      INTEGER                        :: jn
468
469      !!----------------------------------------------------------------------
470     
471      fabm_diag_index = -1
472      DO jn = 1, SIZE(model%diagnostic_variables)
473         IF (TRIM(model%diagnostic_variables(jn)%name) == TRIM(diag_name)) THEN
474            fabm_diag_index = jn
475            EXIT
476         ENDIF
477      END DO
478      IF (fabm_diag_index == -1) THEN
479         CALL ctl_stop( 'Could not find '//TRIM(diag_name)//' diagnostic' )
480      ELSE
481         IF (lwp) WRITE(numout,*) 'Index for '//TRIM(diag_name)//' is: ', fabm_diag_index
482      ENDIF
483   
484   END FUNCTION fabm_diag_index
485
486#else
487   !!----------------------------------------------------------------------
488   !!   Dummy module                                        No FABM model
489   !!----------------------------------------------------------------------
490CONTAINS
491   SUBROUTINE nemo_fabm_init
492   END SUBROUTINE nemo_fabm_init
493
494   SUBROUTINE trc_ini_fabm            ! Empty routine
495   END SUBROUTINE trc_ini_fabm
496#endif
497
498   !!======================================================================
499END MODULE trcini_fabm
Note: See TracBrowser for help on using the repository browser.