/[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.14 by jmc, Sun Nov 23 04:19:11 2003 UTC revision 1.31 by jmc, Tue Nov 28 22:47:13 2006 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.
 C     | These arrays are used throughout the code in evaluating    
 C     | gradients, integrals and spatial avarages. This routine    
 C     | is called separately by each thread and initialise only    
 C     | the region of the domain it is "responsible" for.          
 C     | Notes:                                                      
 C     | Two examples are shown in this code. One illustrates the    
 C     | initialisation of a cartesian grid. The other shows the    
 C     | inialisation of a spherical polar grid. Other orthonormal  
 C     | grids can be fitted into this design. In this case          
 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  
17    
18  C     !USES:  C     !USES:
19        IMPLICIT NONE        IMPLICIT NONE
 C     === Global variables ===  
20  #include "SIZE.h"  #include "SIZE.h"
21  #include "EEPARAMS.h"  #include "EEPARAMS.h"
22  #include "PARAMS.h"  #include "PARAMS.h"
23  #include "GRID.h"  #include "GRID.h"
24    #ifdef ALLOW_MNC
25    #include "MNC_PARAMS.h"
26    #endif
27    #ifdef ALLOW_MONITOR
28    #include "MONITOR.h"
29    #endif
30    
31  C     !INPUT/OUTPUT PARAMETERS:  C     !INPUT/OUTPUT PARAMETERS:
32  C     == Routine arguments ==  C     myThid  :: my Thread Id number
 C     myThid -  Number of this instance of INI_GRID  
33        INTEGER myThid        INTEGER myThid
34    CEOP
35    
36    C     === Functions ====
37          LOGICAL  MASTER_CPU_IO
38          EXTERNAL MASTER_CPU_IO
39    
40  C     !LOCAL VARIABLES:  C     !LOCAL VARIABLES:
41  C     == Local variables ==  C     msgBuf  :: Informational/error message buffer
 C     msgBuf - Used for informational I/O.  
42        CHARACTER*(MAX_LEN_MBUF) msgBuf        CHARACTER*(MAX_LEN_MBUF) msgBuf
43  CEOP  #ifdef ALLOW_MNC
44          INTEGER i
45    #endif
46    
47    C     load grid spacing (vector) from files
48          CALL LOAD_GRID_SPACING( myThid )
49    
50  C--   Set up vertical grid and coordinate system  C     Set up reference vertical profile (vector) for state variables
51    C jmc: this call will not stay here but will move to S/R INITIALISE_FIXED
52    C      (a better place) once anelatic initialisation is cleaned-up.
53          CALL INI_REFERENCE_STATE( myThid )
54    
55    C     Set up vertical grid and coordinate system
56        CALL INI_VERTICAL_GRID( myThid )        CALL INI_VERTICAL_GRID( myThid )
57    
58  C--   Set up horizontal grid and coordinate system  C     Two examples are shown in this code. One illustrates the
59    C     initialization of a cartesian grid. The other shows the
60    C     inialization of a spherical polar grid. Other orthonormal grids
61    C     can be fitted into this design. In this case custom metric terms
62    C     also need adding to account for the projections of velocity
63    C     vectors onto these grids.  The structure used here also makes it
64    C     possible to implement less regular grid mappings. In particular:
65    C      o Schemes which leave out blocks of the domain that are
66    C        all land could be supported.
67    C      o Multi-level schemes such as icosohedral or cubic
68    C        grid projectedions onto a sphere can also be fitted
69    C       within the strategy we use.
70    C        Both of the above also require modifying the support
71    C        routines that map computational blocks to simulation
72    C        domain blocks.
73    
74    C     Set up horizontal grid and coordinate system
75        IF ( usingCartesianGrid ) THEN        IF ( usingCartesianGrid ) THEN
76         CALL INI_CARTESIAN_GRID( myThid )          CALL INI_CARTESIAN_GRID( myThid )
77        ELSEIF ( usingSphericalPolarGrid ) THEN        ELSEIF ( usingSphericalPolarGrid ) THEN
78         CALL INI_SPHERICAL_POLAR_GRID( myThid )          CALL INI_SPHERICAL_POLAR_GRID( myThid )
79        ELSEIF ( usingCurvilinearGrid ) THEN        ELSEIF ( usingCurvilinearGrid ) THEN
80         CALL INI_CURVILINEAR_GRID( myThid )          CALL INI_CURVILINEAR_GRID( myThid )
81          ELSEIF ( usingCylindricalGrid ) THEN
82            CALL INI_CYLINDER_GRID( myThid )
83        ELSE        ELSE
84         _BEGIN_MASTER(myThid)          _BEGIN_MASTER(myThid)
85          WRITE(msgBuf,'(A)')          WRITE(msgBuf,'(2A)') 'S/R INI_GRID: ',
86       &   'S/R INI_GRID: No grid coordinate system has been selected'       &       'No grid coordinate system has been selected'
87           CALL PRINT_ERROR( msgBuf , myThid)          CALL PRINT_ERROR( msgBuf , myThid)
88           STOP 'ABNORMAL END: S/R INI_GRID'          STOP 'ABNORMAL END: S/R INI_GRID'
89         _END_MASTER(myThid)          _END_MASTER(myThid)
90        ENDIF        ENDIF
91    
92  C--   Write certain grid data to files (useful for creating netCDF  #ifdef ALLOW_MONITOR
93  C     and general post-analysis)        IF ( MASTER_CPU_IO(myThid) ) THEN
94        CALL WRITE_FLD_XY_RS( 'XC',' ',XC,0,myThid)  C--   only the master thread is allowed to switch On/Off mon_write_stdout
95        CALL WRITE_FLD_XY_RS( 'YC',' ',YC,0,myThid)  C     & mon_write_mnc (since it's the only thread that uses those flags):
96        CALL WRITE_FLD_XY_RS( 'XG',' ',XG,0,myThid)  
97        CALL WRITE_FLD_XY_RS( 'YG',' ',YG,0,myThid)          IF (monitor_stdio) THEN
98        CALL WRITE_FLD_XY_RS( 'RAC',' ',rA,0,myThid)            mon_write_stdout = .TRUE.
99        CALL WRITE_FLD_XY_RS( 'RAW',' ',rAw,0,myThid)          ELSE
100        CALL WRITE_FLD_XY_RS( 'RAS',' ',rAs,0,myThid)            mon_write_stdout = .FALSE.
101        CALL WRITE_FLD_XY_RS( 'DXG',' ',DXG,0,myThid)          ENDIF
102        CALL WRITE_FLD_XY_RS( 'DYG',' ',DYG,0,myThid)          mon_write_mnc = .FALSE.
103        CALL WRITE_FLD_XY_RS( 'DXC',' ',DXC,0,myThid)  #ifdef ALLOW_MNC
104        CALL WRITE_FLD_XY_RS( 'DYC',' ',DYC,0,myThid)          IF (useMNC .AND. monitor_mnc) THEN
105              DO i = 1,MAX_LEN_MBUF
106                mon_fname(i:i) = ' '
107              ENDDO
108              mon_fname(1:12) = 'monitor_grid'
109              CALL MNC_CW_SET_UDIM(mon_fname, 1, myThid)
110              mon_write_mnc = .TRUE.
111            ENDIF
112    #endif /*  ALLOW_MNC  */
113    
114          ENDIF
115    
116  C--   Print out statistics of each horizontal grid array (helps when debugging)  C     Print out statistics of each horizontal grid array (helps when
117    C     debugging)
118          CALL MON_PRINTSTATS_RS(1,xC,'XC',myThid)
119          CALL MON_PRINTSTATS_RS(1,xG,'XG',myThid)
120          CALL MON_PRINTSTATS_RS(1,dxC,'DXC',myThid)
121          CALL MON_PRINTSTATS_RS(1,dxF,'DXF',myThid)
122          CALL MON_PRINTSTATS_RS(1,dxG,'DXG',myThid)
123          CALL MON_PRINTSTATS_RS(1,dxV,'DXV',myThid)
124          CALL MON_PRINTSTATS_RS(1,yC,'YC',myThid)
125          CALL MON_PRINTSTATS_RS(1,yG,'YG',myThid)
126          CALL MON_PRINTSTATS_RS(1,dyC,'DYC',myThid)
127          CALL MON_PRINTSTATS_RS(1,dyF,'DYF',myThid)
128          CALL MON_PRINTSTATS_RS(1,dyG,'DYG',myThid)
129          CALL MON_PRINTSTATS_RS(1,dyU,'DYU',myThid)
130          CALL MON_PRINTSTATS_RS(1,rA,'RA',myThid)
131          CALL MON_PRINTSTATS_RS(1,rAw,'RAW',myThid)
132          CALL MON_PRINTSTATS_RS(1,rAs,'RAS',myThid)
133          CALL MON_PRINTSTATS_RS(1,rAz,'RAZ',myThid)
134          CALL MON_PRINTSTATS_RS(1,angleCosC,'AngleCS',myThid)
135          CALL MON_PRINTSTATS_RS(1,angleSinC,'AngleSN',myThid)
136    
137          IF ( MASTER_CPU_IO(myThid) ) THEN
138            mon_write_stdout = .FALSE.
139            mon_write_mnc    = .FALSE.
140          ENDIF
141    #endif /* ALLOW_MONITOR */
142    
143  #ifdef ALLOW_MONITOR  C--   Everyone else must wait for the grid to be set
144        CALL MON_PRINTSTATS_RS(1,XC,'XC',myThid)        _BARRIER
       CALL MON_PRINTSTATS_RS(1,XG,'XG',myThid)  
       CALL MON_PRINTSTATS_RS(1,DXC,'DXC',myThid)  
       CALL MON_PRINTSTATS_RS(1,DXF,'DXF',myThid)  
       CALL MON_PRINTSTATS_RS(1,DXG,'DXG',myThid)  
       CALL MON_PRINTSTATS_RS(1,DXV,'DXV',myThid)  
       CALL MON_PRINTSTATS_RS(1,YC,'YC',myThid)  
       CALL MON_PRINTSTATS_RS(1,YG,'YG',myThid)  
       CALL MON_PRINTSTATS_RS(1,DYC,'DYC',myThid)  
       CALL MON_PRINTSTATS_RS(1,DYF,'DYF',myThid)  
       CALL MON_PRINTSTATS_RS(1,DYG,'DYG',myThid)  
       CALL MON_PRINTSTATS_RS(1,DYU,'DYU',myThid)  
       CALL MON_PRINTSTATS_RS(1,RA,'RA',myThid)  
       CALL MON_PRINTSTATS_RS(1,RAW,'RAW',myThid)  
       CALL MON_PRINTSTATS_RS(1,RAS,'RAS',myThid)  
       CALL MON_PRINTSTATS_RS(1,RAZ,'RAZ',myThid)  
 #endif  
145    
146        RETURN        RETURN
147        END        END

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.31

  ViewVC Help
Powered by ViewVC 1.1.22