/[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.19 by jmc, Tue Jul 6 14:40:30 2004 UTC revision 1.34 by jmc, Sun Jun 17 02:20:46 2012 UTC
# Line 6  C $Name$ Line 6  C $Name$
6    
7  CBOP  CBOP
8  C     !ROUTINE: INI_GRID  C     !ROUTINE: INI_GRID
9    
10  C     !INTERFACE:  C     !INTERFACE:
11        SUBROUTINE INI_GRID( myThid )        SUBROUTINE INI_GRID( myThid )
12  C     !DESCRIPTION: \bv  C     !DESCRIPTION:
13  C     *==========================================================*  C     These arrays are used throughout the code in evaluating gradients,
14  C     | SUBROUTINE INI_GRID                                        C     integrals and spatial avarages. This routine is called separately
15  C     | o Initialise model grid                                    C     by each thread and initializes only the region of the domain it is
16  C     *==========================================================*  C     "responsible" for.
17  C     | These arrays are used throughout the code in evaluating    
18  C     | gradients, integrals and spatial avarages. This routine    C     !CALLING SEQUENCE:
19  C     | is called separately by each thread and initialise only    C     INI_GRID
20  C     | the region of the domain it is "responsible" for.          C      |   -- LOAD_GRID_SPACING
21  C     | Notes:                                                      C      |   -- INI_VERTICAL_GRID
22  C     | Two examples are shown in this code. One illustrates the    C      |    / INI_CARTESIAN_GRID
23  C     | initialisation of a cartesian grid. The other shows the    C      |   /  INI_SPHERICAL_POLAR_GRID
24  C     | inialisation of a spherical polar grid. Other orthonormal  C      |   \  INI_CURVILINEAR_GRID
25  C     | grids can be fitted into this design. In this case          C      |    \ INI_CYLINDER_GRID
 C     | custom metric terms also need adding to account for the    
 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     *==========================================================*  
 C     \ev  
26    
27  C     !USES:  C     !USES:
28        IMPLICIT NONE        IMPLICIT NONE
 C     === Global variables ===  
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     !INPUT/OUTPUT PARAMETERS:  C     !INPUT/OUTPUT PARAMETERS:
41  C     == Routine arguments ==  C     myThid  :: my Thread Id number
 C     myThid -  Number of this instance of INI_GRID  
42        INTEGER myThid        INTEGER myThid
43    
44    C     !FUNCTIONS:
45          LOGICAL  MASTER_CPU_IO
46          EXTERNAL MASTER_CPU_IO
47    
48  C     !LOCAL VARIABLES:  C     !LOCAL VARIABLES:
49  C     == Local variables ==  C     bi, bj  :: tile indices
50  C     msgBuf - Used for informational I/O.  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  CEOP
56    
57  C--   Set up vertical grid and coordinate system  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 vertical grid and coordinate system
63        CALL INI_VERTICAL_GRID( myThid )        CALL INI_VERTICAL_GRID( myThid )
64    
65  C--   Set up horizontal grid and coordinate system  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        ELSEIF ( usingCurvilinearGrid ) THEN
87         CALL INI_CURVILINEAR_GRID( myThid )          CALL INI_CURVILINEAR_GRID( myThid )
88        ELSEIF ( usingCylindricalGrid ) THEN        ELSEIF ( usingCylindricalGrid ) THEN
89         CALL INI_CYLINDER( myThid )          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        ENDIF
99    
100  C--   Write certain grid data to files (useful for creating netCDF  C---  Calculate reciprocals grid lengths (formerly part of INI_MASKS_ETC)
101  C     and general post-analysis)        DO bj = myByLo(myThid), myByHi(myThid)
102        CALL WRITE_FLD_XY_RS( 'XC',' ',XC,0,myThid)         DO bi = myBxLo(myThid), myBxHi(myThid)
103        CALL WRITE_FLD_XY_RS( 'YC',' ',YC,0,myThid)          DO j=1-OLy,sNy+OLy
104        CALL WRITE_FLD_XY_RS( 'XG',' ',XG,0,myThid)           DO i=1-OLx,sNx+OLx
105        CALL WRITE_FLD_XY_RS( 'YG',' ',YG,0,myThid)            IF ( dxG(i,j,bi,bj) .NE. 0. )
106        CALL WRITE_FLD_XY_RS( 'RAC',' ',rA,0,myThid)       &    recip_dxG(i,j,bi,bj) = 1. _d 0/dxG(i,j,bi,bj)
107        CALL WRITE_FLD_XY_RS( 'RAW',' ',rAw,0,myThid)            IF ( dyG(i,j,bi,bj) .NE. 0. )
108        CALL WRITE_FLD_XY_RS( 'RAS',' ',rAs,0,myThid)       &    recip_dyG(i,j,bi,bj) = 1. _d 0/dyG(i,j,bi,bj)
109        CALL WRITE_FLD_XY_RS( 'DXG',' ',DXG,0,myThid)            IF ( dxC(i,j,bi,bj) .NE. 0. )
110        CALL WRITE_FLD_XY_RS( 'DYG',' ',DYG,0,myThid)       &    recip_dxC(i,j,bi,bj) = 1. _d 0/dxC(i,j,bi,bj)
111        CALL WRITE_FLD_XY_RS( 'DXC',' ',DXC,0,myThid)            IF ( dyC(i,j,bi,bj) .NE. 0. )
112        CALL WRITE_FLD_XY_RS( 'DYC',' ',DYC,0,myThid)       &    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--   Print out statistics of each horizontal grid array (helps when debugging)  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
135    
136  #ifdef ALLOW_MONITOR  #ifdef ALLOW_MONITOR
137        CALL MON_PRINTSTATS_RS(1,XC,'XC',myThid)        IF ( MASTER_CPU_IO(myThid) ) THEN
138        CALL MON_PRINTSTATS_RS(1,XG,'XG',myThid)  C--   only the master thread is allowed to switch On/Off mon_write_stdout
139        CALL MON_PRINTSTATS_RS(1,DXC,'DXC',myThid)  C     & mon_write_mnc (since it is the only thread that uses those flags):
140        CALL MON_PRINTSTATS_RS(1,DXF,'DXF',myThid)  
141        CALL MON_PRINTSTATS_RS(1,DXG,'DXG',myThid)          IF (monitor_stdio) THEN
142        CALL MON_PRINTSTATS_RS(1,DXV,'DXV',myThid)            mon_write_stdout = .TRUE.
143        CALL MON_PRINTSTATS_RS(1,YC,'YC',myThid)          ELSE
144        CALL MON_PRINTSTATS_RS(1,YG,'YG',myThid)            mon_write_stdout = .FALSE.
145        CALL MON_PRINTSTATS_RS(1,DYC,'DYC',myThid)          ENDIF
146        CALL MON_PRINTSTATS_RS(1,DYF,'DYF',myThid)          mon_write_mnc = .FALSE.
147        CALL MON_PRINTSTATS_RS(1,DYG,'DYG',myThid)  #ifdef ALLOW_MNC
148        CALL MON_PRINTSTATS_RS(1,DYU,'DYU',myThid)          IF (useMNC .AND. monitor_mnc) THEN
149        CALL MON_PRINTSTATS_RS(1,RA,'RA',myThid)            DO i = 1,MAX_LEN_MBUF
150        CALL MON_PRINTSTATS_RS(1,RAW,'RAW',myThid)              mon_fname(i:i) = ' '
151        CALL MON_PRINTSTATS_RS(1,RAS,'RAS',myThid)            ENDDO
152        CALL MON_PRINTSTATS_RS(1,RAZ,'RAZ',myThid)            mon_fname(1:12) = 'monitor_grid'
153  #endif            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
184    #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

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

  ViewVC Help
Powered by ViewVC 1.1.22