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