1 | MODULE 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 : liste 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 | # include "exampl_substitute.h90" |
---|
52 | !!---------------------------------------------------------------------- |
---|
53 | !! NEMO/OPA 3.3 , NEMO Consortium (2010) |
---|
54 | !! $Id$ |
---|
55 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
56 | !!---------------------------------------------------------------------- |
---|
57 | CONTAINS |
---|
58 | |
---|
59 | INTEGER FUNCTION exa_mpl_alloc() |
---|
60 | !!---------------------------------------------------------------------- |
---|
61 | !! *** FUNCTION exa_mpl_alloc *** |
---|
62 | !!---------------------------------------------------------------------- |
---|
63 | ALLOCATE( array(jpi,jpj,jpk) , STAT= exa_mpl_alloc ) ! Module array |
---|
64 | ! |
---|
65 | IF( lk_mpp ) CALL mpp_sum ( exa_mpl_alloc ) |
---|
66 | IF( exa_mpl_alloc /= 0 ) CALL ctl_warn('exa_mpl_alloc: failed to allocate arrays') |
---|
67 | ! |
---|
68 | END FUNCTION exa_mpl_alloc |
---|
69 | |
---|
70 | |
---|
71 | SUBROUTINE exa_mpl( kt, pvar1, pvar2, ptab ) |
---|
72 | !!---------------------------------------------------------------------- |
---|
73 | !! *** ROUTINE exa_mpl *** |
---|
74 | !! |
---|
75 | !! ** Purpose : Brief description of the routine |
---|
76 | !! |
---|
77 | !! ** Method : description of the methodoloy used to achieve the |
---|
78 | !! objectives of the routine. Be as clear as possible! |
---|
79 | !! |
---|
80 | !! ** Action : - first action (share memory array/varible modified |
---|
81 | !! in this routine |
---|
82 | !! - second action ..... |
---|
83 | !! - ..... |
---|
84 | !! |
---|
85 | !! References : Author et al., Short_name_review, Year |
---|
86 | !! Give references if exist otherwise suppress these lines |
---|
87 | !!---------------------------------------------------------------------- |
---|
88 | USE toto_module ! description of the module |
---|
89 | USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released |
---|
90 | USE wrk_nemo, ONLY: zztab => wrk_2d_5 ! 2D workspace |
---|
91 | USE wrk_nemo, ONLY: zwx => wrk_3d_12 , zwy => wrk_3d_13 ! 3D workspace |
---|
92 | !! |
---|
93 | INTEGER , INTENT(in ) :: kt ! short description |
---|
94 | INTEGER , INTENT(inout) :: pvar1 ! - - |
---|
95 | REAL(wp), INTENT( out) :: pvar2 ! - - |
---|
96 | REAL(wp), INTENT( out), DIMENSION(jpi,jpj) :: pvar2 ! - - |
---|
97 | !! |
---|
98 | INTEGER :: ji, jj, jk ! dummy loop arguments (DOCTOR : start with j, but not jp) |
---|
99 | INTEGER :: itoto, itata ! temporary integers (DOCTOR : start with i |
---|
100 | REAL(wp) :: zmlmin, zbbrau ! temporary scalars (DOCTOR : start with z) |
---|
101 | REAL(wp) :: zfact1, zfact2 ! do not use continuation lines in declaration |
---|
102 | !!-------------------------------------------------------------------- |
---|
103 | |
---|
104 | IF( wrk_in_use(3, 12,13) .OR. wrk_in_use(2, 5 ) THEN |
---|
105 | CALL ctl_stop('exa_mpl: requested workspace arrays unavailable') ; RETURN |
---|
106 | ENDIF |
---|
107 | |
---|
108 | IF( kt == nit000 ) CALL exa_mpl_init ! Initialization (first time-step only) |
---|
109 | |
---|
110 | zmlmin = 1.e-8 ! Local constant initialization |
---|
111 | zbbrau = .5 * ebb / rau0 |
---|
112 | zfact1 = -.5 * rdt * efave |
---|
113 | zfact2 = 1.5 * rdt * ediss |
---|
114 | |
---|
115 | SELECT CASE ( npdl ) ! short description of the action |
---|
116 | ! |
---|
117 | CASE ( 0 ) ! describe case 1 |
---|
118 | DO jk = 2, jpkm1 |
---|
119 | DO jj = 2, jpjm1 |
---|
120 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
121 | avmv(ji,jj,jk) = .... |
---|
122 | END DO |
---|
123 | END DO |
---|
124 | END DO |
---|
125 | ! |
---|
126 | CASE ( 1 ) ! describe case 2 |
---|
127 | DO jk = 2, jpkm1 |
---|
128 | DO jj = 2, jpjm1 |
---|
129 | DO ji = fs_2, fs_jpim1 ! vector opt. |
---|
130 | avmv(ji,jj,jk) = ... |
---|
131 | END DO |
---|
132 | END DO |
---|
133 | END DO |
---|
134 | ! |
---|
135 | END SELECT |
---|
136 | ! |
---|
137 | CALL mpplnk2( avmu, 'U', 1. ) ! Lateral boundary conditions (unchanged sign) |
---|
138 | ! |
---|
139 | IF( wrk_not_released(3, 12,13) .OR. wrk_not_released(2, 5 ) THEN |
---|
140 | CALL ctl_stop('exa_mpl: failed to release workspace arrays') ; RETURN |
---|
141 | ENDIF |
---|
142 | ! |
---|
143 | END SUBROUTINE exa_mpl |
---|
144 | |
---|
145 | |
---|
146 | SUBROUTINE exa_mpl_init |
---|
147 | !!---------------------------------------------------------------------- |
---|
148 | !! *** ROUTINE exa_mpl_init *** |
---|
149 | !! |
---|
150 | !! ** Purpose : initialization of .... |
---|
151 | !! |
---|
152 | !! ** Method : blah blah blah ... |
---|
153 | !! |
---|
154 | !! ** input : Namlist namexa |
---|
155 | !! |
---|
156 | !! ** Action : ... |
---|
157 | !!---------------------------------------------------------------------- |
---|
158 | INTEGER :: ji, jj, jk, jit ! dummy loop indices |
---|
159 | !! |
---|
160 | NAMELIST/namexa/ exa_v1, exa_v2, nexa_0, sn_ex |
---|
161 | !!---------------------------------------------------------------------- |
---|
162 | ! |
---|
163 | sn_ex%clname ='toto' ! set default namelist values |
---|
164 | sn_ex%nfreqh = 2 |
---|
165 | ! |
---|
166 | REWIND( numnam ) ! Read Namelist namexa : example parameters |
---|
167 | READ ( numnam, namexa ) |
---|
168 | ! |
---|
169 | IF(lwp) THEN ! Control print |
---|
170 | WRITE(numout,*) |
---|
171 | WRITE(numout,*) 'exa_mpl_init : example ' |
---|
172 | WRITE(numout,*) '~~~~~~~~~~~~' |
---|
173 | WRITE(numout,*) ' Namelist namexa : set example parameters' |
---|
174 | WRITE(numout,*) ' brief desciption exa_v1 = ', exa_v1 |
---|
175 | WRITE(numout,*) ' brief desciption exa_v1 = ', exa_v1 |
---|
176 | WRITE(numout,*) ' brief desciption nexa_0 = ', nexa_0 |
---|
177 | WRITE(numout,*) ' brief desciption sn_ex%clname = ', sn_ex%clname |
---|
178 | WRITE(numout,*) ' brief desciption sn_ex%nfreqh = ', sn_ex%nfreqh |
---|
179 | ENDIF |
---|
180 | ! |
---|
181 | ! ! allocate exa_mpl arrays |
---|
182 | IF( exa_mpl_alloc() /= 0 ) CALL ctl_stop( 'STOP', 'exa_mpl_init : unable to allocate arrays' ) |
---|
183 | ! ! Parameter control |
---|
184 | IF( ln_opt ) CALL ctl_stop( 'exa_mpl_init: this work and option xxx are incompatible' ) |
---|
185 | IF( nn_opt == 2 ) CALL ctl_warn( 'exa_mpl_init: this work and option yyy may cause problems' ) |
---|
186 | ! |
---|
187 | END SUBROUTINE exa_mpl_init |
---|
188 | |
---|
189 | #else |
---|
190 | !!---------------------------------------------------------------------- |
---|
191 | !! Default option : NO example |
---|
192 | !!---------------------------------------------------------------------- |
---|
193 | CONTAINS |
---|
194 | SUBROUTINE exa_mpl( kt, pvar1, pvar2, ptab ) ! Empty routine |
---|
195 | REAL:: ptab(:,:) |
---|
196 | WRITE(*,*) 'exa_mpl: You should not have seen this print! error?', kt, pvar1, pvar2, ptab(1,1) |
---|
197 | END SUBROUTINE exa_mpl |
---|
198 | #endif |
---|
199 | |
---|
200 | !!====================================================================== |
---|
201 | END MODULE exampl |
---|