|
||||
File indexing completed on 2018-03-02 18:36:11 UTC
view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC4c563c2ee9 Chri*0001 CBOI 0002 C 0003 C !TITLE: WRAPPER CODE SYNOPSIS 0004 C !AUTHORS: mitgcm developers ( support@mitgcm.org ) 0005 C !AFFILIATION: Massachussetts Institute of Technology 0006 C !DATE: 1aadaa3d31 Jean*0007 C !INTRODUCTION: b2518cdd0b Ed H*0008 C Wrapper synopsis and code Routines in the subdirectories under 0009 C eesupp/ ( src/ and inc/ ) provide the core framework within which 0010 C numerical and ancilliary software of MITgcm operates. The eesupp/ 0011 C directories provide a collection of software we call {\bf WRAPPER} 0012 C ( ({\bf W}rappable {\bf A}pplication {\bf P}aralell {\bf 0013 C P}rogramming {\bf E}nvironment {\bf R}esource). The {bf WRAPPER} 0014 C provides a generic bootstrapping capability to start applications 0015 C in a manner that allows them to exploit single and 0016 C multi-processing environments on all present day hardware 0017 C platforms (spanning vector SMP systems to distributed memory and 0018 C processing cluster systems). Numerical applications must be coded 0019 C to fit within the {\bf WRAPPER}. This entails applications 0020 C adopting a particular style for declaring data structures 0021 C representing grids and values on grids. The {\bf WRAPPER} 0022 C currently provides support for grid point models using a single 0023 C global indexing system. This is sufficient for latitude-logitude, 0024 C cylindrical, and cartesian coordinate configurations. There is 0025 C also limited support for composing grids in which no single, 0026 C sructured global index can be defined. At present, this support is 0027 C limited to specific configurations of projections of a cube onto 0028 C the sphere. 4c563c2ee9 Chri*0029 C b2518cdd0b Ed H*0030 C The main functions supported by the current {\bf WRAPPER} code are 0031 C \begin{itemize} 0032 C \item program startup and termination including 0033 C creation/management of multiple threads and/or processes 0034 C \item communication and synchronisatioin operations between 0035 C multiple processes and/or threads 0036 C \item multi-process input and output operations to disk and to 0037 C other applications 0038 C \end{itemize} 4c563c2ee9 Chri*0039 C b2518cdd0b Ed H*0040 C Multi-process execution assumes the existence of MPI for process 0041 C startup and termination. However, MPI does not have to be used for 0042 C performance critical operations. Instead, {\bf WRAPPER} 0043 C performance critical parallel primitives are implemented to allow 0044 C them to bind to different low-level system software 0045 C layers. Bindings exist for using {\bf WRAPPER} with portable 0046 C systems such as MPI and UNIX System V IPC memory mapping, as well 0047 C bindings for high-performance propreitary systems such as Myrinet 0048 C GM software and Compaq IMC memory channel technology. b2b90c0df6 Chri*0049 C 4c563c2ee9 Chri*0050 CEOI 0051 924557e60a Chri*0052 C-- Get C preprocessor options 212a8d049e Ed H*0053 #include "PACKAGES_CONFIG.h" 924557e60a Chri*0054 #include "CPP_OPTIONS.h" 0055 b2518cdd0b Ed H*0056 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| 4c563c2ee9 Chri*0057 CBOP 0058 C !ROUTINE: MAIN 0059 0060 C !INTERFACE: 924557e60a Chri*0061 PROGRAM MAIN 0062 4c563c2ee9 Chri*0063 C !DESCRIPTION: 0064 C *==========================================================* 1aadaa3d31 Jean*0065 C | PROGRAM MAIN 0066 C | o MAIN wrapper for MITgcm UV implementation. 4c563c2ee9 Chri*0067 C *==========================================================* 1aadaa3d31 Jean*0068 C | MAIN controls the "execution environment". 0069 C | Its main functions are 4c563c2ee9 Chri*0070 C | 1. call procedure EEBOOT to perform execution environment 1aadaa3d31 Jean*0071 C | initialisation. 2b4c849245 Ed H*0072 C | 2. call procedure THE\_MODEL\_MAIN once for each concurrent 1aadaa3d31 Jean*0073 C | thread. THE\_MODEL\_MAIN is the user supplied top-level 0074 C | routine. 0075 C | 3. call procedure EEDIE to perform execution environment 0076 C | shutdown. 4c563c2ee9 Chri*0077 C *==========================================================* 0078 0079 C !CALLING SEQUENCE: 0080 C 1aadaa3d31 Jean*0081 C main() 4c563c2ee9 Chri*0082 C | 0083 C |--eeboot() :: WRAPPER initilization 0084 C | 0085 C |--check_threads() :: Validate multiple thread start up. 0086 C | 0087 C |--the_model_main() :: Numerical code top-level driver routine 0088 C | 0089 C |--eedie() :: WRAPPER termination 0090 0091 C !USES: 2e14deb8c4 Jean*0092 IMPLICIT NONE 0093 924557e60a Chri*0094 C == Global variables == 0095 C Include all the "shared" data here. That means all common 0096 C blocks used in the model. On many implementations this is not 0097 C necessary but doing this is the safest method. 0098 #include "SIZE.h" 0099 #include "EEPARAMS.h" 0100 #include "EESUPPORT.h" 9333d0f1ff Patr*0101 #include "PARAMS.h" 0102 #include "GRID.h" 0103 #include "DYNVARS.h" 0104 #include "FFIELDS.h" 0105 #include "SURFACE.h" b81731e160 Ed H*0106 #ifdef HAVE_SIGREG 0107 #include "SIGREG.h" 0108 #endif 924557e60a Chri*0109 4c563c2ee9 Chri*0110 C !LOCAL VARIABLES: 2e14deb8c4 Jean*0111 C msgBuf :: I/O message buffer 0112 C I :: loop counter 0113 C myThid :: thread Id number 0114 CHARACTER*(MAX_LEN_MBUF) msgBuf 924557e60a Chri*0115 INTEGER myThid 0116 INTEGER I e4a86aa47e Jean*0117 INTEGER dummyComm a6a74ff42f Chri*0118 0119 #ifdef USE_OMP_THREADING 0120 INTEGER OMP_GET_THREAD_NUM 0121 EXTERNAL OMP_GET_THREAD_NUM 1aadaa3d31 Jean*0122 #endif a6a74ff42f Chri*0123 4c563c2ee9 Chri*0124 CEOP 924557e60a Chri*0125 4a8ea014e3 Cons*0126 #ifdef USE_GSL_IEEE 2e14deb8c4 Jean*0127 CALL FGSL_IEEE_ENV_SETUP () 4a8ea014e3 Cons*0128 #endif 0129 924557e60a Chri*0130 C-- Set up the execution environment 1aadaa3d31 Jean*0131 C EEBOOT loads a execution environment parameter file e4a86aa47e Jean*0132 C ( called "eedata" by default ) and sets variables accordingly. 0133 dummyComm = -1 0134 CALL EEBOOT( dummyComm ) 924557e60a Chri*0135 1aadaa3d31 Jean*0136 C-- Trap errors 924557e60a Chri*0137 IF ( eeBootError ) THEN 0138 fatalError = .TRUE. 0139 GOTO 999 0140 ENDIF 0141 df91541502 Ed H*0142 #ifdef HAVE_SETRLSTK 0143 IF (useSETRLSTK) THEN 0144 CALL setrlstk 0145 ENDIF 0146 #endif 0147 b81731e160 Ed H*0148 #ifdef HAVE_SIGREG 0149 IF (useSIGREG) THEN 0150 i_got_signal = 0 0151 CALL sigreg( i_got_signal ) 0152 ENDIF 0153 #endif 0154 b2518cdd0b Ed H*0155 #ifdef HAVE_PTHREADS 1aadaa3d31 Jean*0156 c IF (usePTHREADS) THEN b2518cdd0b Ed H*0157 CALL PTINIT(nThreads) 1aadaa3d31 Jean*0158 c ELSE b2518cdd0b Ed H*0159 #else 0160 1aadaa3d31 Jean*0161 C-- Start nThreads concurrent threads. 924557e60a Chri*0162 C Note: We do a fiddly check here. The check is performed 0163 C by CHECK_THREADS. CHECK_THREADS does a count 0164 C of all the threads. If after ten seconds it has not 0165 C found nThreads threads are running it flags an 1aadaa3d31 Jean*0166 C error. This traps the case in which the input 0167 C parameter nThreads is different from the actual 924557e60a Chri*0168 C number of concurrent threads the OS gives us. This 46dc4f419b Chri*0169 C case causes a deadlock if we do not trap it here. 924557e60a Chri*0170 #include "MAIN_PDIRECTIVES1.h" 0171 DO I=1,nThreads a6a74ff42f Chri*0172 #ifdef USE_OMP_THREADING 0173 IF ( OMP_GET_THREAD_NUM() .EQ. I-1 ) THEN 1aadaa3d31 Jean*0174 #endif a6a74ff42f Chri*0175 myThid = I 0176 0177 C-- Do check to see if there are nThreads threads running 0178 IF ( .NOT. eeBootError ) THEN 0179 CALL CHECK_THREADS( myThid ) 0180 ENDIF 0181 0182 C-- Invoke nThreads instances of the numerical model 0183 IF ( .NOT. eeBootError ) THEN e7f4654c01 Patr*0184 #if (defined (ALLOW_ADMTLM)) a6a74ff42f Chri*0185 CALL ADMTLM_DSVD(myThid) e7f4654c01 Patr*0186 #elif (defined (ALLOW_HESSIAN_CODE)) 0187 CALL HESSIAN_MAIN(myThid) 7236d20aeb Patr*0188 #else a6a74ff42f Chri*0189 CALL THE_MODEL_MAIN(myThid) 7236d20aeb Patr*0190 #endif a6a74ff42f Chri*0191 ENDIF 0192 0193 C-- Each threads sets flag indicating it is done 0194 threadIsComplete(myThid) = .TRUE. 0195 IF ( .NOT. eeBootError ) THEN 0196 _BARRIER 0197 ENDIF 0198 #ifdef USE_OMP_THREADING 924557e60a Chri*0199 ENDIF 1aadaa3d31 Jean*0200 #endif 924557e60a Chri*0201 ENDDO 0202 #include "MAIN_PDIRECTIVES2.h" 0203 b2518cdd0b Ed H*0204 #endif /* HAVE_PTHREADS */ 0205 924557e60a Chri*0206 999 CONTINUE 0207 C-- Shut down execution environment 0208 CALL EEDIE 0209 0210 C-- Write closedown status 0211 IF ( fatalError ) THEN 2e14deb8c4 Jean*0212 WRITE( msgBuf,'(A)') 'PROGRAM MAIN: ends with fatal Error' 0213 CALL PRINT_ERROR( msgBuf, 1 ) 0214 WRITE(standardMessageUnit,'(A)') 0215 & 'PROGRAM MAIN: ends with fatal Error' 924557e60a Chri*0216 STOP 'ABNORMAL END: PROGRAM MAIN' 0217 ELSE 1aadaa3d31 Jean*0218 WRITE(standardMessageUnit,'(A)') 0219 & 'PROGRAM MAIN: Execution ended Normally' 924557e60a Chri*0220 STOP 'NORMAL END' 0221 ENDIF b2518cdd0b Ed H*0222 1aadaa3d31 Jean*0223 END b2518cdd0b Ed H*0224 0225 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| 0226 0227 CBOP 0 0228 C !ROUTINE: PTREENTRY 1aadaa3d31 Jean*0229 b2518cdd0b Ed H*0230 C !INTERFACE: 1aadaa3d31 Jean*0231 SUBROUTINE PTREENTRY( b2518cdd0b Ed H*0232 I myThid ) 0233 0234 C !DESCRIPTION: 0235 C Re-entry point for a pthreads-based threading mechanism. The 0236 C intent is to produce a threading hack that will work with gcc/g77. 1aadaa3d31 Jean*0237 b2518cdd0b Ed H*0238 C !USES: 2e14deb8c4 Jean*0239 IMPLICIT NONE b2518cdd0b Ed H*0240 #include "SIZE.h" 0241 #include "EEPARAMS.h" 0242 #include "EESUPPORT.h" 9333d0f1ff Patr*0243 #include "PARAMS.h" 0244 #include "GRID.h" 0245 #include "DYNVARS.h" 0246 #include "FFIELDS.h" 0247 #include "SURFACE.h" b2518cdd0b Ed H*0248 0249 C !INPUT PARAMETERS: 2e14deb8c4 Jean*0250 C myThid :: my thread Id number 0251 INTEGER myThid b2518cdd0b Ed H*0252 CEOP 0253 2e14deb8c4 Jean*0254 WRITE(*,*) 'myThid = ', myThid b2518cdd0b Ed H*0255 CALL CHECK_THREADS( myThid ) 0256 1aadaa3d31 Jean*0257 c CALL THE_MODEL_MAIN(myThid) b2518cdd0b Ed H*0258 0259 threadIsComplete(myThid) = .TRUE. 0260 0261 RETURN 0262 END 0263 0264 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated from https://github.com/MITgcm/MITgcm by the 2.2.1-MITgcm-0.1 LXR engine. The LXR team |