Guest User

config_cmaq

a guest
Mar 26th, 2024
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.80 KB | None | 0 0
  1. #!/bin/csh -f
  2.  
  3. # ================= CMAQv5.4.X Configuration Script ================= #
  4. # Requirements: I/O API & netCDF libraries #
  5. # PGI, Intel, or Gnu Fortran compiler #
  6. # MPICH for multiprocessor computing #
  7. # Optional: Git for GitHub source code repository #
  8. # #
  9. # Note that this script was configured/tested on Red Hat Linux O/S #
  10. # #
  11. # To report problems or request help with this script/program: #
  12. # http://www.cmascenter.org/help-desk.cfm #
  13. # =================================================================== #
  14.  
  15. #> Critical Folder Locations
  16. # CMAQ_HOME - this is where the config_cmaq.csh script is located. It
  17. # is also the root directory for all the executables. It may include
  18. # the repository if the user is building CMAQ inside the repository. It
  19. # may, on the other hand, be outside the repository if the user has
  20. # created a separate project directory where they wish to put build-
  21. # and run-scripts as well as executables.
  22. setenv CMAQ_HOME $cwd
  23.  
  24. # CMAQ_REPO - this is always the location of the CMAQ repository that
  25. # the user will pull from to create exectuables. If the user is building
  26. # CMAQ inside the repository then it will be equal to CMAQ_HOME. If not,
  27. # the user must supply an alternative folder locaiton.
  28. setenv CMAQ_REPO $CMAQ_HOME
  29.  
  30. # CMAQ_DATA - this may be where the input data are located. It may be a
  31. # symbolic link to another location on the system, but it should be
  32. # provided here
  33. setenv CMAQ_DATA $CMAQ_HOME/data
  34. if ( ! -d $CMAQ_DATA ) mkdir -p $CMAQ_DATA
  35.  
  36. cd $CMAQ_HOME
  37.  
  38. #===============================================================================
  39. #> architecture & compiler specific settings
  40. #===============================================================================
  41.  
  42. #> Set the compiler option
  43. if ( $#argv == 1 ) then
  44. #> Use the user's input to set the compiler parameter
  45. setenv compiler $1
  46. setenv compilerVrsn Empty
  47. else if ( $#argv == 2 ) then
  48. #> Compiler Name and Version have been provided
  49. setenv compiler $1
  50. setenv compilerVrsn $2
  51. else if ( $#argv == 0 ) then
  52. #> If config.cmaq is called from Bldit.cctm or run.cctm, then this
  53. #> variable is already defined
  54. if ( ! $?compiler ) then
  55. echo "Error: 'compiler' should be set either in the"
  56. echo " environment or as input to config.cmaq"
  57. echo " Example:> ./config.cmaq [compiler]"
  58. echo " Options: intel | gcc | pgi"
  59. exit
  60. else if ( ! $?compilerVrsn ) then
  61. setenv compilerVrsn Empty
  62. endif
  63. else
  64. #> More than two inputs were given. Exit this script just to
  65. #> be on the safe side.
  66. echo "Error: Too many inputs to config.cmaq. This script"
  67. echo " is expecting one input (the name of the"
  68. echo " desired compiler. In some installations, you "
  69. echo " may also be able to specify the compiler version "
  70. echo " as the second input, but this is not by default."
  71. exit
  72. endif
  73. echo "Compiler is set to $compiler"
  74.  
  75.  
  76. #> Compiler flags and settings
  77. switch ( $compiler )
  78.  
  79. #> Intel fortran compiler......................................................
  80. case intel:
  81.  
  82. #> I/O API, netCDF Library Locations -- used in WRF-CMAQ
  83. setenv NETCDF netcdf_root_intel # Note please combine netCDF-C & Fortran Libraries
  84. setenv IOAPI ioapi_root_intel
  85. setenv WRF_ARCH # [1-75]
  86.  
  87. #> I/O API, netCDF, and MPI Library Locations -- used in CMAQ
  88. setenv IOAPI_INCL_DIR ioapi_inc_intel #> I/O API include header files
  89. setenv IOAPI_LIB_DIR ioapi_lib_intel #> I/O API libraries
  90. setenv NETCDF_LIB_DIR netcdf_lib_intel #> netCDF C directory path
  91. setenv NETCDF_INCL_DIR netcdf_inc_intel #> netCDF C directory path
  92. setenv NETCDFF_LIB_DIR netcdff_lib_intel #> netCDF Fortran directory path
  93. setenv NETCDFF_INCL_DIR netcdff_inc_intel #> netCDF Fortran directory path
  94. setenv MPI_INCL_DIR mpi_incl_intel #> MPI Include directory path
  95. setenv MPI_LIB_DIR mpi_lib_intel #> MPI Lib directory path
  96.  
  97. #> Compiler Aliases and Flags
  98. #> set the compiler flag -qopt-report=5 to get a model optimization report in the build directory with the optrpt extension
  99. setenv myFC mpiifort
  100. setenv myCC icc
  101. setenv myFSTD "-O3 -fno-alias -mp1 -fp-model source -ftz -simd -align all -xHost -vec-guard-write -unroll-aggressive"
  102. setenv myDBG "-O0 -g -check bounds -check uninit -fpe0 -fno-alias -ftrapuv -traceback"
  103. setenv myLINK_FLAG #"-qopenmp-simd" openMP not supported w/ CMAQ
  104. setenv myFFLAGS "-fixed -132"
  105. setenv myFRFLAGS "-free"
  106. setenv myCFLAGS "-O2"
  107. setenv extra_lib ""
  108.  
  109. breaksw
  110.  
  111. #> Portland Group fortran compiler.............................................
  112. case pgi:
  113.  
  114. #> I/O API, netCDF Library Locations -- used in WRF-CMAQ
  115. setenv NETCDF netcdf_root_pgi # Note please combine netCDF-C & Fortran Libraries
  116. setenv IOAPI ioapi_root_pgi
  117. setenv WRF_ARCH # [1-75]
  118.  
  119. #> I/O API, netCDF, and MPI Library Locations -- used in CMAQ
  120. setenv IOAPI_INCL_DIR iopai_inc_pgi #> I/O API include header files
  121. setenv IOAPI_LIB_DIR ioapi_lib_pgi #> I/O API libraries
  122. setenv NETCDF_LIB_DIR netcdf_lib_pgi #> netCDF C directory path
  123. setenv NETCDF_INCL_DIR netcdf_inc_pgi #> netCDF C directory path
  124. setenv NETCDFF_LIB_DIR netcdff_lib_pgi #> netCDF Fortran directory path
  125. setenv NETCDFF_INCL_DIR netcdff_inc_pgi #> netCDF Fortran directory path
  126. setenv MPI_INCL_DIR mpi_incl_pgi #> MPI Include directory path
  127. setenv MPI_LIB_DIR mpi_lib_pgi #> MPI Lib directory path
  128.  
  129. #> Compiler Aliases and Flags
  130. setenv myFC mpifort
  131. setenv myCC pgcc
  132. setenv myLINK_FLAG # "-mp" openMP not supported w/ CMAQ
  133. setenv myFSTD "-O3"
  134. setenv myDBG "-O0 -g -Mbounds -Mchkptr -traceback -Ktrap=fp"
  135. setenv myFFLAGS "-Mfixed -Mextend -mcmodel=medium -tp px"
  136. setenv myFRFLAGS "-Mfree -Mextend -mcmodel=medium -tp px"
  137. setenv myCFLAGS "-O2"
  138. setenv extra_lib ""
  139.  
  140. breaksw
  141.  
  142. #> gfortran compiler............................................................
  143. case gcc:
  144.  
  145. #> I/O API, netCDF Library Locations -- used in WRF-CMAQ
  146. setenv NETCDF netcdf_root_gcc # Note please combine netCDF-C & Fortran Libraries
  147. setenv IOAPI ioapi_root_gcc
  148. setenv WRF_ARCH # [1-75]
  149.  
  150. #> I/O API, netCDF, and MPI Library Locations -- used in CMAQ
  151. setenv IOAPI_INCL_DIR /scratch/gap6/LIBRARIES/ioapi-3.2/ioapi/fixed_src #> I/O API include header files
  152. setenv IOAPI_LIB_DIR /scratch/gap6/LIBRARIES/ioapi-3.2/Linux2_x86_64gfort_gcc_9.3.0 #> I/O API libraries
  153. setenv NETCDF_LIB_DIR /scratch/gap6/LIBRARIES/netcdf/lib #> netCDF C directory path
  154. setenv NETCDF_INCL_DIR /scratch/gap6/LIBRARIES/netcdf/include #> netCDF C directory path
  155. setenv NETCDFF_LIB_DIR /scratch/gap6/LIBRARIES/netcdf/lib #> netCDF Fortran directory path
  156. setenv NETCDFF_INCL_DIR /scratch/gap6/LIBRARIES/netcdf/include #> netCDF Fortran directory path
  157. setenv MPI_INCL_DIR /opt/apps/software/OpenMPI/4.0.3-GCC-9.3.0/include #> MPI Include directory path
  158. setenv MPI_LIB_DIR /opt/apps/software/OpenMPI/4.0.3-GCC-9.3.0/lib #> MPI Lib directory path
  159.  
  160. #> Compiler Aliases and Flags
  161. #> set the compiler flag -fopt-info-missed to generate a missed optimization report in the bldit logfile
  162. setenv myFC mpifort
  163. setenv myCC gcc
  164. setenv myFSTD "-O3 -funroll-loops -finit-character=32 -Wtabs -Wsurprising -ftree-vectorize -ftree-loop-if-convert -finline-limit=512"
  165. setenv myDBG "-Wall -O0 -g -fcheck=all -ffpe-trap=invalid,zero,overflow -fbacktrace"
  166. setenv myFFLAGS "-ffixed-form -ffixed-line-length-132 -funroll-loops -finit-character=32"
  167. setenv myFRFLAGS "-ffree-form -ffree-line-length-none -funroll-loops -finit-character=32"
  168. setenv myCFLAGS "-O2"
  169. setenv myLINK_FLAG ""# "-fopenmp" # openMP not supported w/ CMAQ
  170. setenv extra_lib ""
  171.  
  172. breaksw
  173.  
  174. default:
  175. echo "*** Compiler $compiler not found"
  176. exit(2)
  177. breaksw
  178.  
  179. endsw
  180.  
  181. #> Apply Specific Module and Library Location Settings for those working inside EPA
  182. # source /work/MOD3DEV/cmaq_common/cmaq_env.csh #>>> UNCOMMENT if at EPA
  183.  
  184. #> Add The Complier Version Number to the Compiler String if it's not empty
  185. setenv compilerString ${compiler}
  186. if ( $compilerVrsn != "Empty" ) then
  187. setenv compilerString ${compiler}${compilerVrsn}
  188. endif
  189.  
  190. #===============================================================================
  191.  
  192. #> I/O API, netCDF, and MPI libraries
  193. setenv netcdf_lib "-lnetcdf" #> -lnetcdff -lnetcdf for netCDF v4.2.0 and later
  194. setenv netcdff_lib "-lnetcdff"
  195. setenv ioapi_lib "-lioapi"
  196. setenv pnetcdf_lib "-lpnetcdf"
  197. setenv mpi_lib "-lmpi" #> -lmpich or -lmvapich
  198.  
  199. #> Query System Info and Current Working Directory
  200. setenv system "`uname -m`"
  201. setenv bld_os "`uname -s``uname -r | cut -d. -f1`"
  202. setenv lib_basedir $CMAQ_HOME/lib
  203.  
  204. #> Generate Library Locations
  205. setenv CMAQ_LIB ${lib_basedir}/${system}/${compilerString}
  206. setenv MPI_DIR $CMAQ_LIB/mpi
  207. setenv NETCDF_DIR $CMAQ_LIB/netcdf
  208. setenv NETCDFF_DIR $CMAQ_LIB/netcdff
  209. setenv PNETCDF_DIR $CMAQ_LIB/pnetcdf
  210. setenv IOAPI_DIR $CMAQ_LIB/ioapi
  211.  
  212. #> Create Symbolic Links to Libraries
  213. if ( ! -d $CMAQ_LIB ) mkdir -p $CMAQ_LIB
  214. if ( -e $MPI_DIR ) rm -rf $MPI_DIR
  215. mkdir $MPI_DIR
  216. ln -s $MPI_LIB_DIR $MPI_DIR/lib
  217. ln -s $MPI_INCL_DIR $MPI_DIR/include
  218. if ( ! -d $NETCDF_DIR ) mkdir $NETCDF_DIR
  219. if ( ! -e $NETCDF_DIR/lib ) ln -sfn $NETCDF_LIB_DIR $NETCDF_DIR/lib
  220. if ( ! -e $NETCDF_DIR/include ) ln -sfn $NETCDF_INCL_DIR $NETCDF_DIR/include
  221. if ( ! -d $NETCDFF_DIR ) mkdir $NETCDFF_DIR
  222. if ( ! -e $NETCDFF_DIR/lib ) ln -sfn $NETCDFF_LIB_DIR $NETCDFF_DIR/lib
  223. if ( ! -e $NETCDFF_DIR/include ) ln -sfn $NETCDFF_INCL_DIR $NETCDFF_DIR/include
  224. if ( ! -d $IOAPI_DIR ) then
  225. mkdir $IOAPI_DIR
  226. ln -sfn $IOAPI_INCL_DIR $IOAPI_DIR/include_files
  227. ln -sfn $IOAPI_LIB_DIR $IOAPI_DIR/lib
  228. endif
  229.  
  230. #> Check for netcdf and I/O API libs/includes, error if they don't exist
  231. if ( ! -e $NETCDF_DIR/lib/libnetcdf.a ) then
  232. echo "ERROR: $NETCDF_DIR/lib/libnetcdf.a does not exist in your CMAQ_LIB directory!!! Check your installation before proceeding with CMAQ build."
  233. exit
  234. endif
  235. if ( ! -e $NETCDFF_DIR/lib/libnetcdff.a ) then
  236. echo "ERROR: $NETCDFF_DIR/lib/libnetcdff.a does not exist in your CMAQ_LIB directory!!! Check your installation before proceeding with CMAQ build."
  237. exit
  238. endif
  239. if ( ! -e $IOAPI_DIR/lib/libioapi.a ) then
  240. echo "ERROR: $IOAPI_DIR/lib/libioapi.a does not exist in your CMAQ_LIB directory!!! Check your installation before proceeding with CMAQ build."
  241. exit
  242. endif
  243. if ( ! -e $IOAPI_DIR/lib/m3utilio.mod ) then
  244. echo "ERROR: $IOAPI_MOD_DIR/m3utilio.mod does not exist in your CMAQ_LIB directory!!! Check your installation before proceeding with CMAQ build."
  245. exit
  246. endif
  247.  
  248. #> Set executable id
  249. setenv EXEC_ID ${bld_os}_${system}${compilerString}
  250.  
Advertisement
Add Comment
Please, Sign In to add comment