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.
module_example.F90 in NEMO/branches/UKMO/NEMO_r4.2RC_GO8_package/src/OCE – NEMO

source: NEMO/branches/UKMO/NEMO_r4.2RC_GO8_package/src/OCE/module_example.F90 @ 15608

Last change on this file since 15608 was 15080, checked in by ayoung, 3 years ago

GO8 package merge, essential changes only. Ticket #2648.

  • Property svn:keywords set to Id
File size: 9.9 KB
Line 
1MODULE exampl
2   !!======================================================================
3   !!                       ***  MODULE  exampl  ***
4   !! Ocean physics:  brief description of the purpose of the module
5   !!                 (please no more than 2 lines)
6   !!======================================================================
7   !! History : 3.0  !  2008-06  (Author Names)  Original code
8   !!            -   !  2008-08  (Author names)  brief description of modifications
9   !!           3.3  !  2010-11  (Author names)        -              -
10   !!----------------------------------------------------------------------
11#if defined key_example
12   !!----------------------------------------------------------------------
13   !!   'key_example'  :                brief description of the key option
14   !!----------------------------------------------------------------------
15   !!   exa_mpl       : list of module subroutine (caution, never use the
16   !!   exa_mpl_init  : name of the module for a routine)
17   !!   exa_mpl_stp   : Please try to use 3 letter block for routine names
18   !!----------------------------------------------------------------------
19   USE module_name1   ! brief description of the used module
20   USE module_name2   ! ....
21
22   IMPLICIT NONE
23   PRIVATE
24
25   PUBLIC   exa_mpl        ! routine called in xxx.F90 module
26   PUBLIC   exa_mpl_init   ! routine called in nemogcm.F90 module
27
28   TYPE ::   FLD_E                !: Structure type definition
29      CHARACTER(lc) ::   clname      ! clname description (default length, lc, is 256, see par_kind.F90)
30      INTEGER       ::   nfreqh      ! nfreqh description
31   END TYPE FLD_E 
32
33   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   var1         !: var1 description. CAUTION always use !: to describe
34   !                                                          !  a PUBLIC variable: simplify its search :
35   !                                                          !  grep var1 *90 | grep '!:'
36   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   var2, var2   !: several variable on a same line OK, but
37   !                                                          !  DO NOT use continuation lines in declaration
38
39   !                               !!* namelist nam_xxx *
40   LOGICAL   ::   ln_opt = .TRUE.   ! give the default value of each namelist parameter
41   CHARACTER ::   cn_tex = 'T'      ! short description  of the variable
42   INTEGER   ::   nn_opt = 1        ! please respect the DOCTOR norm for namelist variable
43   REAL(wp)  ::   rn_var = 2._wp    ! (it becomes easy to identify them in the code)
44   TYPE(FLD) ::   sn_ex             ! structure
45
46   INTEGER                          ::   nint    ! nint  description (local permanent variable)
47   REAL(wp)                         ::   var     ! var         -                -
48   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   array   ! array       -                -
49
50   !! * Substitutions
51   ! for DO macro
52#  include "do_loop_substitute.h90"
53   !for other substitutions
54   !!----------------------------------------------------------------------
55   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
56   !! $Id$
57   !! Software governed by the CeCILL license (see ./LICENSE)
58   !!----------------------------------------------------------------------
59CONTAINS
60
61   INTEGER FUNCTION exa_mpl_alloc()
62      !!----------------------------------------------------------------------
63      !!                ***  FUNCTION exa_mpl_alloc  ***
64      !!----------------------------------------------------------------------
65      ALLOCATE( array(jpi,jpj,jpk) , STAT= exa_mpl_alloc )   ! Module array                                                               
66      !
67      CALL mpp_sum ( 'module_example', exa_mpl_alloc )
68      IF( exa_mpl_alloc /= 0 )   CALL ctl_stop( 'STOP', 'exa_mpl_alloc: failed to allocate arrays' )
69      !
70   END FUNCTION exa_mpl_alloc
71   
72
73   SUBROUTINE exa_mpl( kt, pvar1, pvar2, ptab )
74      !!----------------------------------------------------------------------
75      !!                    ***  ROUTINE exa_mpl  ***
76      !!
77      !! ** Purpose :   Brief description of the routine
78      !!
79      !! ** Method  :   description of the methodoloy used to achieve the
80      !!                objectives of the routine. Be as clear as possible!
81      !!
82      !! ** Action  : - first action (share memory array/varible modified
83      !!                in this routine
84      !!              - second action .....
85      !!              - .....
86      !!
87      !! References :   Author et al., Short_name_review, Year
88      !!                Give references if exist otherwise suppress these lines
89      !!----------------------------------------------------------------------
90      INTEGER , INTENT(in   )                     ::   kt      ! short description
91      INTEGER , INTENT(inout)                     ::   pvar1   !   -         -
92      REAL(wp), INTENT(  out)                     ::   pvar2   !   -         -
93      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   pvar2   !   -         -
94      !!
95      INTEGER  ::   ji, jj, jk       ! dummy loop arguments  (DOCTOR : start with j, but not jp)
96      INTEGER  ::   itoto, itata     ! temporary integers    (DOCTOR : start with i
97      REAL(wp) ::   zmlmin, zbbrho   ! temporary scalars     (DOCTOR : start with z)
98      REAL(wp) ::   zfact1, zfact2   ! do not use continuation lines in declaration
99      REAL(wp), DIMENSION(A2D(nn_hls))     ::   zwrk_2d   ! 2D workspace
100      REAL(wp), DIMENSION(A2D(nn_hls),jpk) ::   zwrk_3d   ! 3D workspace
101      !!--------------------------------------------------------------------
102      !
103      IF( .NOT. l_istiled .OR. ntile == 1 )  THEN                       ! Do only on the first tile
104         IF( kt == nit000  )   CALL exa_mpl_init    ! Initialization (first time-step only)
105
106         zmlmin = 1.e-8                             ! Local constant initialization
107         zbbrho =  .5 * ebb / rho0
108         zfact1 = -.5 * rdt * efave
109         zfact2 = 1.5 * rdt * ediss
110      ENDIF
111     
112      SELECT CASE ( npdl )                       ! short description of the action
113      !
114      CASE ( 0 )                                      ! describe case 1
115         DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 )
116            avm(ji,jj,jk) = ....
117         END_3D
118         !
119      CASE ( 1 )                                      ! describe case 2
120         DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 )
121            avm(ji,jj,jk) = ....
122         END_3D
123         !
124      END SELECT
125      !
126      ! WARNING! the lbc_lnk call could not be compatible with the tiling approach
127      ! please refer to the manual for how to adapt your code
128      CALL lbc_lnk( 'module_example', avm, 'T', 1. )     ! Lateral boundary conditions (unchanged sign)
129      !
130   END SUBROUTINE exa_mpl
131
132
133   SUBROUTINE exa_mpl_init
134      !!----------------------------------------------------------------------
135      !!                  ***  ROUTINE exa_mpl_init  ***
136      !!                   
137      !! ** Purpose :   initialization of ....
138      !!
139      !! ** Method  :   blah blah blah ...
140      !!
141      !! ** input   :   Namlist namexa
142      !!
143      !! ** Action  :   ... 
144      !!----------------------------------------------------------------------
145      INTEGER ::   ji, jj, jk, jit   ! dummy loop indices
146      INTEGER  ::   ios              ! Local integer output status for namelist read
147      !!
148      NAMELIST/namexa/ exa_v1, exa_v2, nexa_0, sn_ex     
149      !!----------------------------------------------------------------------
150      !
151      REWIND( numnam_ref )              ! Namelist namexa in reference namelist : Example
152      READ  ( numnam_ref, namexa, IOSTAT = ios, ERR = 901)
153901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namexa in reference namelist' )
154      !
155      REWIND( numnam_cfg )              ! Namelist namexa in configuration namelist : Example
156      READ  ( numnam_cfg, namexa, IOSTAT = ios, ERR = 902 )
157902   IF( ios >  0 ) CALL ctl_nam ( ios , 'namexa in configuration namelist' )
158   ! Output namelist for control
159      WRITE ( numond, namexa )
160      !
161      IF(lwp) THEN                              ! Control print
162         WRITE(numout,*)
163         WRITE(numout,*) 'exa_mpl_init : example '
164         WRITE(numout,*) '~~~~~~~~~~~~'
165         WRITE(numout,*) '   Namelist namexa : set example parameters'
166         WRITE(numout,*) '      brief desciption               exa_v1  = ', exa_v1
167         WRITE(numout,*) '      brief desciption               exa_v2  = ', exa_v2
168         WRITE(numout,*) '      brief desciption               nexa_0  = ', nexa_0
169         WRITE(numout,*) '      brief desciption          sn_ex%clname = ', sn_ex%clname
170         WRITE(numout,*) '      brief desciption          sn_ex%nfreqh = ', sn_ex%nfreqh
171      ENDIF
172      !
173      !                              ! allocate exa_mpl arrays     
174      IF( exa_mpl_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'exa_mpl_init : unable to allocate arrays' )
175      !                              ! Parameter control
176      IF( ln_tile ) CALL ctl_stop( 'exa_mpl_init: tiling is not supported in this module by default, see manual for how to adapt your code' )
177      IF( ln_opt      )   CALL ctl_stop( 'exa_mpl_init: this work and option xxx are incompatible'   )
178      IF( nn_opt == 2 )   CALL ctl_stop( 'STOP',  'exa_mpl_init: this work and option yyy may cause problems'  )
179      !
180   END SUBROUTINE exa_mpl_init
181
182#else
183   !!----------------------------------------------------------------------
184   !!   Default option :                                         NO example
185   !!----------------------------------------------------------------------
186CONTAINS
187   SUBROUTINE exa_mpl( kt, pvar1, pvar2, ptab )              ! Empty routine
188      INTEGER :: kt
189      REAL::   pvar1, pvar2, ptab(:,:)
190      WRITE(*,*) 'exa_mpl: You should not have seen this print! error?', kt, pvar1, pvar2, ptab(1,1)
191   END SUBROUTINE exa_mpl
192#endif
193
194   !!======================================================================
195END MODULE exampl
Note: See TracBrowser for help on using the repository browser.