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.
Changeset 1041 – NEMO

Changeset 1041


Ignore:
Timestamp:
2008-05-31T18:42:52+02:00 (16 years ago)
Author:
gm
Message:

trunk: module_example update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEMO/OPA_SRC/module_example

    r247 r1041  
    11MODULE exampl 
    22   !!====================================================================== 
    3    !!                       ***  MODULE  example  *** 
     3   !!                       ***  MODULE  exampl  *** 
    44   !! Ocean physics:  brief description of the purpose of the module 
    55   !!                 (please no more than 2 lines) 
    6    !!===================================================================== 
     6   !!====================================================================== 
     7   !! History : 3.0  !  2008-06  (Author Names)  Original code 
     8   !!            -   !  2008-08  (Author names)  brief description of modifications 
     9   !!           3.1  !  2008-12  (Author names)        -              - 
     10   !!---------------------------------------------------------------------- 
     11 
    712#if defined key_example 
    813   !!---------------------------------------------------------------------- 
    914   !!   'key_example'  :                brief description of the key option 
    1015   !!---------------------------------------------------------------------- 
    11    !!   exa_mpl      : liste of module subroutine (caution, never use the 
    12    !!   exa_mpl_init : name of the module for a routine) 
    13    !!   exa_mpl_stp  : Please try to use 3 letter block for routine names 
     16   !!   exa_mpl       : liste of module subroutine (caution, never use the 
     17   !!   exa_mpl_init  : name of the module for a routine) 
     18   !!   exa_mpl_stp   : Please try to use 3 letter block for routine names 
    1419   !!---------------------------------------------------------------------- 
    15    !! * Modules used 
    16    USE module_name1            ! brief description of the used module 
    17    USE module_name2            ! .... 
     20   USE module_name1   ! brief description of the used module 
     21   USE module_name2   ! .... 
    1822 
    1923   IMPLICIT NONE 
    2024   PRIVATE 
    2125 
    22    !! *  Routine accessibility 
    23    PUBLIC exa_mpl    ! routine called in xxx.F90 module 
     26   PUBLIC   exa_mpl   ! routine called in xxx.F90 module 
    2427 
    25    !! * Share Module variables 
    26    REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   &  !: 
    27       var1    ,   &  !: var1 description (CAUTION always use !: to describe a  
    28       !              !  PUBLIC variable simplify the search of where it is declared 
    29       var2           !: var2 description 
     28   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   var1         !: var1 description. CAUTION always use !: to describe 
     29   !                                                          !  a PUBLIC variable: simplify its search :  
     30   !                                                          !  grep var1 *90 | grep '!:' 
     31   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   var2, var2   !: several variable on a same line OK, but  
     32   !                                                          !  DO NOT use continuation lines in declaration 
    3033 
    31    !! * Module variables 
    32    INTEGER ::                 & !!! ** toto namelist (namtoto) ** 
    33       nflag  =  1                ! default value of nflag  
    34    REAL(wp) ::                & !!! ** toto namlist (namtoto) ** 
    35       var3  = 2._wp / 9._wp      ! default value of var3 
    36    REAL(wp) ::   &   
    37       var4          ! var4 description (local permanent variable) 
    38    REAL(wp), DIMENSION(jpi,jpj,jpk) ::   & 
    39       tab1          ! coefficient used for horizontal smoothing 
     34   !                             !!! ** namelist nam_xxx ** 
     35   LOGICAL  ::   ln_opt = 1       ! give the default value of each namelist parameter 
     36   CHARACTER::   cn_tex = 'T'     ! short description  of the variable 
     37   INTEGER  ::   nn_opt = 1       ! please respect the DOCTOR norm for namelist variable 
     38   REAL(wp) ::   rn_var = 2._wp   ! (it becomes easy to identify them in the code) 
     39 
     40   INTEGER                          ::   nint    ! nint description (local permanent variable) 
     41   REAL(wp)                         ::   var     ! var         -                - 
     42   REAL(wp), DIMENSION(jpi,jpj,jpk) ::   array   ! array       -                - 
    4043 
    4144   !! * Substitutions 
    4245#  include "exampl_substitute.h90" 
    4346   !!---------------------------------------------------------------------- 
    44    !!  OPA 9.0 , LOCEAN-IPSL (2005)  
    45    !! or LIM 2.0 , UCL-LOCEAN-IPSL (2005) 
    46    !! or  TOP 1.0 , LOCEAN-IPSL (2005) 
    47    !! $Header$  
    48    !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
     47   !! NEMO/OPA 3.0 , LOCEAN-IPSL (2008)  
     48   !! $Id:$  
     49   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) 
    4950   !!---------------------------------------------------------------------- 
    5051 
    5152CONTAINS 
    5253 
    53 # if defined key_autotasking 
    54    !!---------------------------------------------------------------------- 
    55    !!   'key_autotasking'                              autotasking (j-slab) 
    56    !!---------------------------------------------------------------------- 
    57 #  include "exampl_autotsk.h90" 
    58  
    59 # else 
    60    !!---------------------------------------------------------------------- 
    61    !!   Default option :                           vector opt. (k-j-i loop) 
    62    !!---------------------------------------------------------------------- 
    63  
    64    SUBROUTINE exa_mpl( kt ) 
     54   SUBROUTINE exa_mpl( kt, pvar1, pvar2, ptab ) 
    6555      !!---------------------------------------------------------------------- 
    6656      !!                    ***  ROUTINE exa_mpl  *** 
     
    6959      !! 
    7060      !! ** Method  :   description of the methodoloy used to achieve the 
    71       !!      objectives of the routine. Be as clear as possible! 
     61      !!                objectives of the routine. Be as clear as possible! 
    7262      !! 
    7363      !! ** Action  : - first action (share memory array/varible modified 
     
    7666      !!              - ..... 
    7767      !! 
    78       !! References : 
    79       !!   Give references if exist otherwise suppress these lines 
     68      !! References :   Author et al., Short_name_review, Year 
     69      !!                Give references if exist otherwise suppress these lines 
     70      !!---------------------------------------------------------------------- 
     71      USE toto_module      ! description od the module 
    8072      !! 
    81       !! History : 
    82       !!   9.0  !  03-08  (Autor Names)  Original code 
    83       !!        !  02-08  (Author names)  brief description of modifications 
    84       !!---------------------------------------------------------------------- 
    85       !! * Modules used 
    86       USE toto_module                ! description od the module 
    87  
    88       !! * arguments 
    89       INTEGER, INTENT( in  ) ::   &   
    90          kt                          ! describe it!!! 
    91  
    92       !! * local declarations 
    93       INTEGER ::   ji, jj, jk        ! dummy loop arguments 
    94       INTEGER ::   & 
    95          itoto, itata,            &  ! temporary integers 
    96          ititi                       ! please do not forget the DOCTOR rule: 
    97          !                           ! local integer: name start with i 
    98       REAL(wp) ::   & 
    99          zmlmin, zbbrau,          &  ! temporary scalars 
    100          zfact1, zfact2, zfact3,  &  !    "         " 
    101          zbn2, zesurf,            &  ! local scalar: name start with z 
    102          zemxl                       ! 
    103       REAL(wp), DIMENSION(jpi,jpk) ::   & 
    104          ztoto                       ! temporary workspace 
     73      INTEGER , INTENT(in   )                     ::   kt      ! short description  
     74      INTEGER , INTENT(inout)                     ::   pvar1   !   -         - 
     75      REAL(wp), INTENT(  out)                     ::   pvar2   !   -         - 
     76      REAL(wp), INTENT(  out), DIMENSION(jpi,jpj) ::   pvar2   !   -         - 
     77      !! 
     78      INTEGER  ::   ji, jj, jk       ! dummy loop arguments  (DOCTOR : start with j, but not jp) 
     79      INTEGER  ::   itoto, itata     ! temporary integers    (DOCTOR : start with i 
     80      REAL(wp) ::   zmlmin, zbbrau   ! temporary scalars     (DOCTOR : start with z) 
     81      REAL(wp) ::   zfact1, zfact2   ! do not use continuation lines in declaration 
     82      REAL(wp), DIMENSION(jpi,jpk) ::   ztoto   ! 2D workspace 
    10583      !!-------------------------------------------------------------------- 
    106  
    107  
    10884 
    10985      IF( kt == nit000  )   CALL exa_mpl_init    ! Initialization (first time-step only) 
    11086 
    111       ! Local constant initialization 
    112       zmlmin = 1.e-8 
     87      zmlmin = 1.e-8                             ! Local constant initialization 
    11388      zbbrau =  .5 * ebb / rau0 
    11489      zfact1 = -.5 * rdt * efave 
    11590      zfact2 = 1.5 * rdt * ediss 
    116       zfact3 = 0.5 * rdt * ediss 
    11791 
    118  
    119       SELECT CASE ( npdl ) 
    120  
    121       CASE ( 0 )           ! describe case 1 
     92      SELECT CASE ( npdl )                       ! short description of the action 
     93      ! 
     94      CASE ( 0 )                                      ! describe case 1 
    12295         DO jk = 2, jpkm1 
    12396            DO jj = 2, jpjm1 
     
    127100            END DO 
    128101         END DO 
    129  
    130       CASE ( 1 )           ! describe case 2 
     102         ! 
     103      CASE ( 1 )                                      ! describe case 2 
    131104         DO jk = 2, jpkm1 
    132105            DO jj = 2, jpjm1 
     
    136109            END DO 
    137110         END DO 
    138  
     111         ! 
    139112      END SELECT 
    140113 
    141       ! Lateral boundary conditions (avmu)   (unchanged sign) 
    142       CALL mpplnk2( avmu, 'U', 1. ) 
    143  
     114      CALL mpplnk2( avmu, 'U', 1. )              ! Lateral boundary conditions (avmu)   (unchanged sign) 
     115      ! 
    144116   END SUBROUTINE exa_mpl 
    145117 
    146 # endif 
    147118 
    148119   SUBROUTINE exa_mpl_init 
     
    157128      !! 
    158129      !! ** Action  :   ...   
     130      !!---------------------------------------------------------------------- 
     131      INTEGER ::   ji, jj, jk, jit   ! dummy loop indices 
    159132      !! 
    160       !! history : 
    161       !!   9.0  !  03-08  (Autor Names)  Original code 
     133      NAMELIST/namexa/ exa_v1, exa_v2, nexa_0        
    162134      !!---------------------------------------------------------------------- 
    163       !! * local declarations 
    164       INTEGER ::   ji, jj, jk, jit   ! dummy loop indices 
    165  
    166       NAMELIST/namexa/ exa_v1, exa_v2, nexa_0   
    167       !!---------------------------------------------------------------------- 
    168  
    169       ! Read Namelist namexa : example parameters 
    170       REWIND ( numnam ) 
     135      ! 
     136      REWIND ( numnam )                          ! Read Namelist namexa : example parameters 
    171137      READ   ( numnam, namexa ) 
    172  
    173  
    174       ! Control print 
    175       IF(lwp) THEN 
     138      ! 
     139      IF(lwp) THEN                               ! Control print 
    176140         WRITE(numout,*) 
    177141         WRITE(numout,*) 'exa_mpl_init : example ' 
     
    182146         WRITE(numout,*) '             brief desciption               nexa_0  = ', nexa_0 
    183147      ENDIF 
    184  
    185       ! Parameter control 
    186 #if defined key_toto 
    187       IF(lwp) WRITE(numout,cform_err) 
    188       IF(lwp) WRITE(numout,*) '          this part and key_toto are incompatible' 
    189       nstop = nstop + 1 
    190 #endif 
    191  
    192       ! Check nexa_0 values 
    193       IF( nexa_0 < 0 ) THEN 
    194          IF(lwp) WRITE(numout,cform_err) 
    195          IF(lwp) WRITE(numout,*) '          bad flag: nmxl is < 0 or > 3 ' 
    196          nstop = nstop + 1 
     148      ! 
     149      !                                          ! Parameter control 
     150      IF( ln_opt  )   CALL ctl_stop( 'this work and option xxx are incompatible'   ) 
     151      IF( ln_opt2 )   CALL ctl_warn( 'this work and option yyy may cause problems' ) 
    197152      ENDIF 
    198  
     153      ! 
    199154   END SUBROUTINE exa_mpl_init 
    200155 
    201156#else 
    202157   !!---------------------------------------------------------------------- 
    203    !!   Default option :                                       Empty module 
     158   !!   Default option :                                         NO example 
    204159   !!---------------------------------------------------------------------- 
    205160CONTAINS 
    206    SUBROUTINE exa_mpl              ! Empty routine 
     161   SUBROUTINE exa_mpl( kt, pvar1, pvar2, ptab )              ! Empty routine 
     162      REAL::   ptab(:,:) 
     163      WRITE(*,*) 'exa_mpl: You should not have seen this print! error?', kt, pvar1, pvar2, ptab(1,1) 
    207164   END SUBROUTINE exa_mpl 
    208165#endif 
Note: See TracChangeset for help on using the changeset viewer.