/[MITgcm]/MITgcm/model/src/ini_grid.F
ViewVC logotype

Diff of /MITgcm/model/src/ini_grid.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1 by cnh, Wed Apr 22 19:15:30 1998 UTC revision 1.34 by jmc, Sun Jun 17 02:20:46 2012 UTC
# Line 1  Line 1 
1  C $Id$  C $Header$
2    C $Name$
3    
4  #include "CPP_EEOPTIONS.h"  #include "PACKAGES_CONFIG.h"
5    #include "CPP_OPTIONS.h"
6    
7  CStartOfInterface  CBOP
8    C     !ROUTINE: INI_GRID
9    
10    C     !INTERFACE:
11        SUBROUTINE INI_GRID( myThid )        SUBROUTINE INI_GRID( myThid )
12  C     /==========================================================\  C     !DESCRIPTION:
13  C     | SUBROUTINE INI_GRID                                      |  C     These arrays are used throughout the code in evaluating gradients,
14  C     | o Initialise model grid                                  |  C     integrals and spatial avarages. This routine is called separately
15  C     |==========================================================|  C     by each thread and initializes only the region of the domain it is
16  C     | These arrays are used throughout the code in evaluating  |  C     "responsible" for.
17  C     | gradients, integrals and spatial avarages. This routine  |  
18  C     | is called separately by each thread and initialise only  |  C     !CALLING SEQUENCE:
19  C     | the region of the domain it is "responsible" for.        |  C     INI_GRID
20  C     | Notes:                                                   |  C      |   -- LOAD_GRID_SPACING
21  C     | Two examples are shown in this code. One illustrates the |  C      |   -- INI_VERTICAL_GRID
22  C     | initialisation of a cartesian grid. The other shows the  |  C      |    / INI_CARTESIAN_GRID
23  C     | inialisation of a spherical polar grid. Other orthonormal|  C      |   /  INI_SPHERICAL_POLAR_GRID
24  C     | grids can be fitted into this design. In this case       |  C      |   \  INI_CURVILINEAR_GRID
25  C     | custom metric terms also need adding to account for the  |  C      |    \ INI_CYLINDER_GRID
 C     | projections of velocity vectors onto these grids.        |  
 C     | The structure used here also makes it possible to        |  
 C     | implement less regular grid mappings. In particular      |  
 C     | o Schemes which leave out blocks of the domain that are  |  
 C     |   all land could be supported.                           |  
 C     | o Multi-level schemes such as icosohedral or cubic       |  
 C     |   grid projectedions onto a sphere can also be fitted    |  
 C     |   within the strategy we use.                            |  
 C     |   Both of the above also require modifying the support   |  
 C     |   routines that map computational blocks to simulation   |  
 C     |   domain blocks.                                         |  
 C     \==========================================================/  
26    
27  C     === Global variables ===  C     !USES:
28          IMPLICIT NONE
29  #include "SIZE.h"  #include "SIZE.h"
30  #include "EEPARAMS.h"  #include "EEPARAMS.h"
31  #include "PARAMS.h"  #include "PARAMS.h"
32  #include "GRID.h"  #include "GRID.h"
33    #ifdef ALLOW_MNC
34    #include "MNC_PARAMS.h"
35    #endif
36    #ifdef ALLOW_MONITOR
37    #include "MONITOR.h"
38    #endif
39    
40  C     == Routine arguments ==  C     !INPUT/OUTPUT PARAMETERS:
41  C     myThid -  Number of this instance of INI_GRID  C     myThid  :: my Thread Id number
42        INTEGER myThid        INTEGER myThid
 CEndOfInterface  
43    
44  C     == Local variables ==  C     !FUNCTIONS:
45  C     msgBuf - Used for informational I/O.        LOGICAL  MASTER_CPU_IO
46          EXTERNAL MASTER_CPU_IO
47    
48    C     !LOCAL VARIABLES:
49    C     bi, bj  :: tile indices
50    C     i, j    :: Loop counters
51    C     msgBuf  :: Informational/error message buffer
52          INTEGER bi, bj
53          INTEGER i, j
54        CHARACTER*(MAX_LEN_MBUF) msgBuf        CHARACTER*(MAX_LEN_MBUF) msgBuf
55    CEOP
56    
57    C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
58    
59    C     Load grid spacing (vector) from files
60          CALL LOAD_GRID_SPACING( myThid )
61    
62  C--   Set up grid coordinate system  C     Set up vertical grid and coordinate system
63          CALL INI_VERTICAL_GRID( myThid )
64    
65    C     Two examples are shown in this code. One illustrates the
66    C     initialization of a cartesian grid. The other shows the
67    C     inialization of a spherical polar grid. Other orthonormal grids
68    C     can be fitted into this design. In this case custom metric terms
69    C     also need adding to account for the projections of velocity
70    C     vectors onto these grids.  The structure used here also makes it
71    C     possible to implement less regular grid mappings. In particular:
72    C      o Schemes which leave out blocks of the domain that are
73    C        all land could be supported.
74    C      o Multi-level schemes such as icosohedral or cubic
75    C        grid projectedions onto a sphere can also be fitted
76    C       within the strategy we use.
77    C        Both of the above also require modifying the support
78    C        routines that map computational blocks to simulation
79    C        domain blocks.
80    
81    C     Set up horizontal grid and coordinate system
82        IF ( usingCartesianGrid ) THEN        IF ( usingCartesianGrid ) THEN
83         CALL INI_CARTESIAN_GRID( myThid )          CALL INI_CARTESIAN_GRID( myThid )
84        ELSEIF ( usingSphericalPolarGrid ) THEN        ELSEIF ( usingSphericalPolarGrid ) THEN
85         CALL INI_SPHERICAL_POLAR_GRID( myThid )          CALL INI_SPHERICAL_POLAR_GRID( myThid )
86          ELSEIF ( usingCurvilinearGrid ) THEN
87            CALL INI_CURVILINEAR_GRID( myThid )
88          ELSEIF ( usingCylindricalGrid ) THEN
89            CALL INI_CYLINDER_GRID( myThid )
90        ELSE        ELSE
91         _BEGIN_MASTER(myThid)          _BEGIN_MASTER(myThid)
92          WRITE(msgBuf,'(A)')          WRITE(msgBuf,'(2A)') 'S/R INI_GRID: ',
93       &   'S/R INI_GRID: No grid coordinate system has been selected'       &       'No grid coordinate system has been selected'
94           CALL PRINT_ERROR( msgBuf , myThid)          CALL PRINT_ERROR( msgBuf , myThid)
95           STOP 'ABNORMAL END: S/R INI_GRID'          CALL ALL_PROC_DIE( 0 )
96         _END_MASTER(myThid)          STOP 'ABNORMAL END: S/R INI_GRID'
97            _END_MASTER(myThid)
98          ENDIF
99    
100    C---  Calculate reciprocals grid lengths (formerly part of INI_MASKS_ETC)
101          DO bj = myByLo(myThid), myByHi(myThid)
102           DO bi = myBxLo(myThid), myBxHi(myThid)
103            DO j=1-OLy,sNy+OLy
104             DO i=1-OLx,sNx+OLx
105              IF ( dxG(i,j,bi,bj) .NE. 0. )
106         &    recip_dxG(i,j,bi,bj) = 1. _d 0/dxG(i,j,bi,bj)
107              IF ( dyG(i,j,bi,bj) .NE. 0. )
108         &    recip_dyG(i,j,bi,bj) = 1. _d 0/dyG(i,j,bi,bj)
109              IF ( dxC(i,j,bi,bj) .NE. 0. )
110         &    recip_dxC(i,j,bi,bj) = 1. _d 0/dxC(i,j,bi,bj)
111              IF ( dyC(i,j,bi,bj) .NE. 0. )
112         &    recip_dyC(i,j,bi,bj) = 1. _d 0/dyC(i,j,bi,bj)
113              IF ( dxF(i,j,bi,bj) .NE. 0. )
114         &    recip_dxF(i,j,bi,bj) = 1. _d 0/dxF(i,j,bi,bj)
115              IF ( dyF(i,j,bi,bj) .NE. 0. )
116         &    recip_dyF(i,j,bi,bj) = 1. _d 0/dyF(i,j,bi,bj)
117              IF ( dxV(i,j,bi,bj) .NE. 0. )
118         &    recip_dxV(i,j,bi,bj) = 1. _d 0/dxV(i,j,bi,bj)
119              IF ( dyU(i,j,bi,bj) .NE. 0. )
120         &    recip_dyU(i,j,bi,bj) = 1. _d 0/dyU(i,j,bi,bj)
121              IF ( rA (i,j,bi,bj) .NE. 0. )
122         &    recip_rA (i,j,bi,bj) = 1. _d 0/rA (i,j,bi,bj)
123              IF ( rAs(i,j,bi,bj) .NE. 0. )
124         &    recip_rAs(i,j,bi,bj) = 1. _d 0/rAs(i,j,bi,bj)
125              IF ( rAw(i,j,bi,bj) .NE. 0. )
126         &    recip_rAw(i,j,bi,bj) = 1. _d 0/rAw(i,j,bi,bj)
127              IF ( rAz(i,j,bi,bj) .NE. 0. )
128         &    recip_rAz(i,j,bi,bj) = 1. _d 0/rAz(i,j,bi,bj)
129             ENDDO
130            ENDDO
131           ENDDO
132          ENDDO
133    
134    C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
135    
136    #ifdef ALLOW_MONITOR
137          IF ( MASTER_CPU_IO(myThid) ) THEN
138    C--   only the master thread is allowed to switch On/Off mon_write_stdout
139    C     & mon_write_mnc (since it is the only thread that uses those flags):
140    
141            IF (monitor_stdio) THEN
142              mon_write_stdout = .TRUE.
143            ELSE
144              mon_write_stdout = .FALSE.
145            ENDIF
146            mon_write_mnc = .FALSE.
147    #ifdef ALLOW_MNC
148            IF (useMNC .AND. monitor_mnc) THEN
149              DO i = 1,MAX_LEN_MBUF
150                mon_fname(i:i) = ' '
151              ENDDO
152              mon_fname(1:12) = 'monitor_grid'
153              CALL MNC_CW_SET_UDIM(mon_fname, 1, myThid)
154              mon_write_mnc = .TRUE.
155            ENDIF
156    #endif /*  ALLOW_MNC  */
157    
158          ENDIF
159    
160    C     Print out statistics of each horizontal grid array (helps when debugging)
161          CALL MON_PRINTSTATS_RS(1,xC,'XC',myThid)
162          CALL MON_PRINTSTATS_RS(1,xG,'XG',myThid)
163          CALL MON_PRINTSTATS_RS(1,dxC,'DXC',myThid)
164          CALL MON_PRINTSTATS_RS(1,dxF,'DXF',myThid)
165          CALL MON_PRINTSTATS_RS(1,dxG,'DXG',myThid)
166          CALL MON_PRINTSTATS_RS(1,dxV,'DXV',myThid)
167          CALL MON_PRINTSTATS_RS(1,yC,'YC',myThid)
168          CALL MON_PRINTSTATS_RS(1,yG,'YG',myThid)
169          CALL MON_PRINTSTATS_RS(1,dyC,'DYC',myThid)
170          CALL MON_PRINTSTATS_RS(1,dyF,'DYF',myThid)
171          CALL MON_PRINTSTATS_RS(1,dyG,'DYG',myThid)
172          CALL MON_PRINTSTATS_RS(1,dyU,'DYU',myThid)
173          CALL MON_PRINTSTATS_RS(1,rA,'RA',myThid)
174          CALL MON_PRINTSTATS_RS(1,rAw,'RAW',myThid)
175          CALL MON_PRINTSTATS_RS(1,rAs,'RAS',myThid)
176          CALL MON_PRINTSTATS_RS(1,rAz,'RAZ',myThid)
177          CALL MON_PRINTSTATS_RS(1,angleCosC,'AngleCS',myThid)
178          CALL MON_PRINTSTATS_RS(1,angleSinC,'AngleSN',myThid)
179    
180          IF ( MASTER_CPU_IO(myThid) ) THEN
181            mon_write_stdout = .FALSE.
182            mon_write_mnc    = .FALSE.
183        ENDIF        ENDIF
184  C  #endif /* ALLOW_MONITOR */
185    
186    C--   Everyone else must wait for the grid to be set
187          _BARRIER
188    
189        RETURN        RETURN
190        END        END
   
 C     $Id$  

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.34

  ViewVC Help
Powered by ViewVC 1.1.22