00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 MODULE shr_inputInfo_mod
00060
00061
00062
00063 USE shr_kind_mod, ONLY : SHR_KIND_CS, SHR_KIND_CL, SHR_KIND_IN, &
00064 SHR_KIND_R8, SHR_KIND_I8
00065 USE shr_sys_mod, ONLY : shr_sys_flush, shr_sys_abort
00066 USE shr_ncio_mod, ONLY : shr_ncio_descripType, shr_ncio_open, &
00067 shr_ncio_close
00068 use shr_log_mod, ONLY : s_loglev => shr_log_Level
00069 use shr_log_mod, ONLY : s_logunit => shr_log_Unit
00070
00071 implicit none
00072
00073 private
00074
00075
00076
00077 public :: shr_inputInfo_initType
00078
00079
00080
00081 public :: shr_inputInfo_initSetDefaults
00082 public :: shr_inputInfo_initPrint
00083 public :: shr_inputInfo_initGetData
00084 public :: shr_inputInfo_initPutData
00085 public :: shr_inputInfo_initRead
00086 public :: shr_inputInfo_initIsStartup
00087 public :: shr_inputInfo_initIsRestart
00088 public :: shr_inputInfo_initIsContinue
00089 public :: shr_inputInfo_initIsBranch
00090 public :: shr_inputInfo_initIsSame
00091 public :: shr_inputInfo_initRestRead
00092 public :: shr_inputInfo_initRestWrite
00093 public :: shr_inputInfo_initRPointerRead
00094 public :: shr_inputInfo_initRPointerWrite
00095 public :: shr_inputInfo_initCheck
00096
00097
00098
00099
00100 character(len=*), public, parameter :: shr_inputInfo_NLFilename = "namelist"
00101
00102 character(len=*), public, parameter :: shr_inputInfo_start_type_start = "startup"
00103 character(len=*), public, parameter :: shr_inputInfo_start_type_cont = "continue"
00104 character(len=*), public, parameter :: shr_inputInfo_start_type_brnch = "branch"
00105
00106
00107
00108 integer, parameter :: NVars = 11
00109
00110 character(len=*), parameter :: shr_inputInfo_saveRestart(NVars) = (/
00111 "case_desc ",
00112 "case_name ",
00113 "version ",
00114 "username ",
00115 "hostname ",
00116 "atm_adiabatic ",
00117 "atm_ideal_phys ",
00118 "aqua_planet ",
00119 "single_column ",
00120 "scmlat ",
00121 "scmlon "
00122 /)
00123
00124
00125
00126 type shr_inputInfo_initType
00127 private
00128
00129
00130
00131
00132
00133 character(SHR_KIND_CL) :: start_type
00134 character(SHR_KIND_CS) :: logFilePostFix
00135 character(SHR_KIND_CL) :: outPathRoot
00136
00137
00138
00139 character(SHR_KIND_CL) :: case_desc
00140 character(SHR_KIND_CS) :: case_name
00141 character(SHR_KIND_CL) :: version
00142 character(SHR_KIND_CL) :: username
00143 character(SHR_KIND_CL) :: hostname
00144
00145 logical :: atm_adiabatic
00146 logical :: atm_ideal_phys
00147 logical :: aqua_planet
00148 logical :: single_column
00149 real (SHR_KIND_R8) :: scmlat
00150 real (SHR_KIND_R8) :: scmlon
00151 integer(SHR_KIND_IN) :: info_debug
00152
00153
00154
00155
00156
00157
00158 logical :: lnd_present
00159 logical :: ice_present
00160 logical :: ocn_present
00161 logical :: rof_present
00162 logical :: atm_prognostic
00163 logical :: lnd_prognostic
00164 logical :: ice_prognostic
00165 logical :: ocn_prognostic
00166 logical :: ocnrof_prognostic
00167 logical :: samegrid
00168 logical :: dead_comps
00169
00170 logical :: userest_atm
00171 logical :: userest_lnd
00172 logical :: userest_ocn
00173 logical :: userest_ice
00174
00175 character(SHR_KIND_CL) :: restart_pfile
00176 character(SHR_KIND_CL) :: restart_file
00177 character(SHR_KIND_CL) :: restart_file_override
00178 logical :: brnch_retain_casename
00179
00180
00181
00182
00183 type(shr_ncio_descripType) :: var(NVars)
00184 end type shr_inputInfo_InitType
00185
00186
00187
00188 character(len=*), private, parameter :: restartFileOverRideList =
00189 ":case_name"
00190 //":case_desc"
00191 //":version"
00192 //":username"
00193 //":hostname"
00194
00195
00196
00197 character(len=*), parameter :: prefix = "shr_inputInfo_"
00198 character(len=*), parameter :: LogPrefix = "(shr_inputInfo) "
00199 character(len=*), parameter :: FAA = "('"//LogPrefix//"',A)"
00200
00201
00202 CONTAINS
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215 SUBROUTINE shr_inputInfo_initSetDefaults( CCSMInit )
00216
00217
00218
00219 USE shr_ncio_mod, ONLY: shr_ncio_descripInit, shr_ncio_descripSetDefault
00220 USE shr_string_mod, ONLY: shr_string_listGetNum, shr_string_listIntersect, &
00221 shr_string_listGetName
00222
00223 implicit none
00224
00225
00226
00227
00228
00229 type(shr_inputInfo_InitType), intent(INOUT) :: CCSMInit
00230
00231
00232
00233
00234 character(len=*), parameter :: subname = '(shr_inputInfo_initSetDefaults) '
00235 character(len=SHR_KIND_CL) :: restartList
00236 character(len=SHR_KIND_CL) :: name
00237 integer :: n
00238 integer :: rc
00239 logical :: init
00240
00241
00242
00243
00244
00245
00246
00247
00248 CCSMInit%case_desc = ' '
00249 CCSMInit%case_name = ' '
00250 CCSMInit%version = ' '
00251 CCSMInit%username = ' '
00252 CCSMInit%hostname = ' '
00253 CCSMInit%start_type = ' '
00254
00255 CCSMInit%atm_ideal_phys = .false.
00256 CCSMInit%atm_adiabatic = .false.
00257 CCSMInit%aqua_planet = .false.
00258 CCSMInit%single_column = .false.
00259 CCSMInit%scmlat = -999.
00260 CCSMInit%scmlon = -999.
00261
00262 CCSMInit%restart_pfile = ' '
00263 CCSMInit%restart_file = ' '
00264 CCSMInit%restart_file_override = ' '
00265 CCSMInit%brnch_retain_casename = .false.
00266 CCSMInit%logFilePostFix = '.log'
00267 CCSMInit%outPathRoot = './'
00268
00269 CCSMInit%lnd_present = .true.
00270 CCSMInit%ice_present = .true.
00271 CCSMInit%ocn_present = .true.
00272 CCSMInit%rof_present = .true.
00273
00274 CCSMInit%atm_prognostic = .false.
00275 CCSMInit%lnd_prognostic = .false.
00276 CCSMInit%ice_prognostic = .false.
00277 CCSMInit%ocn_prognostic = .false.
00278 CCSMInit%ocnrof_prognostic = .false.
00279
00280 CCSMInit%samegrid = .false.
00281 CCSMInit%dead_comps = .false.
00282 CCSMInit%info_debug = 1
00283
00284
00285
00286
00287 call shr_ncio_descripSetDefault( NVars, CCSMInit%var )
00288 do n = 1, NVars
00289 name = shr_inputInfo_saveRestart(n)
00290 if ( trim(name) == "atm_adiabatic" )then
00291 call shr_ncio_descripInit( CCSMInit%var(n), name, &
00292 LongName="Atmosphere runs in adiabatic mode", &
00293 LogicalData=.true. )
00294 else if ( trim(name) == "atm_ideal_phys" )then
00295 call shr_ncio_descripInit( CCSMInit%var(n), name, &
00296 LongName="Atmosphere runs in idealized physics mode", &
00297 LogicalData=.true. )
00298 else if ( trim(name) == "aqua_planet" )then
00299 call shr_ncio_descripInit( CCSMInit%var(n), name, &
00300 LongName="Aqua_planet mode (no-land/ice, "// &
00301 "perpetual-date, and analytic SST)", &
00302 LogicalData=.true. )
00303 else if ( trim(name) == "single_column" )then
00304 call shr_ncio_descripInit( CCSMInit%var(n), name, &
00305 LongName="CCSM run in Single Column Mode", &
00306 LogicalData=.true. )
00307 else if ( trim(name) == "scmlat" )then
00308 call shr_ncio_descripInit( CCSMInit%var(n), name, &
00309 LongName="Single Column Mode Latitude", &
00310 units="degrees_north", RealR8Data=.true. )
00311 else if ( trim(name) == "scmlon" )then
00312 call shr_ncio_descripInit( CCSMInit%var(n), name, &
00313 LongName="Single Column Mode Longitude", &
00314 units="degrees_east", RealR8Data=.true. )
00315 else if ( trim(name) == "case_desc" )then
00316 call shr_ncio_descripInit( CCSMInit%var(n), name, &
00317 LongName="Case description", &
00318 StringData=.true. )
00319 else if ( trim(name) == "case_name" )then
00320 call shr_ncio_descripInit( CCSMInit%var(n), name, &
00321 LongName="Case identification name", &
00322 StringData=.true. )
00323 else if ( trim(name) == "version" )then
00324 call shr_ncio_descripInit( CCSMInit%var(n), name, &
00325 LongName="Code version name or description", &
00326 StringData=.true. )
00327 else if ( trim(name) == "username" )then
00328 call shr_ncio_descripInit( CCSMInit%var(n), name, &
00329 LongName="username of person running this simulation", &
00330 StringData=.true. )
00331 else if ( trim(name) == "hostname" )then
00332 call shr_ncio_descripInit( CCSMInit%var(n), name, &
00333 LongName="hostname of machine running this simulation", &
00334 StringData=.true. )
00335 else
00336 call shr_sys_abort( subname//': unrecognized variable to store ' // &
00337 'on restart file: '//name )
00338 end if
00339 end do
00340
00341 END SUBROUTINE shr_inputInfo_initSetDefaults
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353 SUBROUTINE shr_inputInfo_initPrint( CCSMInit )
00354
00355 implicit none
00356
00357
00358
00359 type(shr_inputInfo_initType), intent(IN) :: CCSMInit
00360
00361
00362
00363
00364 character(len=*), parameter :: subname = '(shr_inputInfo_initPrint) '
00365 character(len=*), parameter :: F0A = "('"//LogPrefix//"',A,T45,' = ', A)"
00366 character(len=*), parameter :: F0L = "('"//LogPrefix//"',A,T45,' = ', L1)"
00367 character(len=*), parameter :: F0I = "('"//LogPrefix//"',A,T45,' = ', I4)"
00368 character(len=*), parameter :: F01 = "('"//LogPrefix//"',A,T45,' = ', f18.13)"
00369
00370
00371
00372
00373
00374 if (s_loglev > 0) then
00375 write(s_logunit,F0A) 'Case description: ', trim(CCSMInit%case_desc)
00376 write(s_logunit,F0A) 'Case name: ', trim(CCSMInit%case_name)
00377 write(s_logunit,F0A) 'Version: ', trim(CCSMInit%version)
00378 write(s_logunit,F0A) 'Username: ', trim(CCSMInit%username)
00379 write(s_logunit,F0A) 'Hostname: ', trim(CCSMInit%hostname)
00380 write(s_logunit,F0A) 'Start type: ', trim(CCSMInit%start_type)
00381 write(s_logunit,F0A) 'Log output ending name: ', trim(CCSMInit%logFilePostFix)
00382
00383 write(s_logunit,*) 'info_debug: ', CCSMInit%info_debug
00384 write(s_logunit,F0A) 'Output path root directory: ', trim(CCSMInit%outPathRoot)
00385 write(s_logunit,F0L) 'atm idealized-physics mode: ', CCSMInit%atm_ideal_phys
00386 write(s_logunit,F0L) 'atm adiabatic mode: ', CCSMInit%atm_adiabatic
00387 write(s_logunit,F0L) 'aqua_planet mode: ', CCSMInit%aqua_planet
00388 write(s_logunit,F0L) 'single_column: ', CCSMInit%single_column
00389 if ( CCSMInit%single_column )then
00390 write(s_logunit,F01) 'scmlat: ', CCSMInit%scmlat
00391 write(s_logunit,F01) 'scmlon: ', CCSMInit%scmlon
00392 end if
00393 write(s_logunit,F0A) 'Restart pointer file: ', trim(CCSMInit%restart_pfile)
00394
00395
00396 if ( shr_inputInfo_initIsRestart( CCSMInit ) )then
00397 if ( shr_inputInfo_initIsBranch( CCSMInit ) ) &
00398 write(s_logunit,F0A) 'Restart file (full path): ', trim(CCSMInit%restart_file)
00399 if ( len_trim(CCSMInit%restart_file_override) == 0 )then
00400 write(s_logunit,FAA) 'Do NOT override any values from restart_file by namelist'
00401 else
00402 write(s_logunit,F0A) 'Restart file override list: ', &
00403 trim(CCSMInit%restart_file_override)
00404 end if
00405 end if
00406 endif
00407
00408 END SUBROUTINE shr_inputInfo_initPrint
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420 SUBROUTINE shr_inputInfo_initGetData( CCSMInit, case_name, case_desc, &
00421 version, username, hostname, &
00422 start_type, restart_pfile, &
00423 restart_file, perpetual_run, &
00424 perpetual_ymd, aqua_planet, &
00425 atm_ideal_phys, atm_adiabatic, &
00426 brnch_retain_casename, single_column, &
00427 scmlat,scmlon, &
00428 logFilePostFix, outPathRoot, &
00429 lnd_present, ice_present, ocn_present, rof_present, &
00430 atm_prognostic, lnd_prognostic, ice_prognostic, &
00431 ocn_prognostic, ocnrof_prognostic, &
00432 dead_comps, samegrid, info_debug)
00433
00434 implicit none
00435
00436
00437
00438 type(shr_inputInfo_InitType), intent(IN) :: CCSMInit
00439 character(len=*), optional, intent(OUT) :: case_name
00440 character(len=*), optional, intent(OUT) :: case_desc
00441 character(len=*), optional, intent(OUT) :: version
00442 character(len=*), optional, intent(OUT) :: username
00443 character(len=*), optional, intent(OUT) :: hostname
00444 character(len=*), optional, intent(OUT) :: start_type
00445 character(len=*), optional, intent(OUT) :: restart_pfile
00446 character(len=*), optional, intent(OUT) :: restart_file
00447 logical, optional, intent(OUT) :: perpetual_run
00448 integer, optional, intent(OUT) :: perpetual_ymd
00449 logical, optional, intent(OUT) :: aqua_planet
00450 logical, optional, intent(OUT) :: atm_adiabatic
00451 logical, optional, intent(OUT) :: atm_ideal_phys
00452 character(len=*), optional, intent(OUT) :: logFilePostFix
00453 character(len=*), optional, intent(OUT) :: outPathRoot
00454 logical, optional, intent(OUT) :: brnch_retain_casename
00455 logical, optional, intent(OUT) :: single_column
00456 real (SHR_KIND_R8), optional, intent(OUT) :: scmlat
00457 real (SHR_KIND_R8), optional, intent(OUT) :: scmlon
00458
00459 logical, optional, intent(OUT) :: dead_comps
00460 logical, optional, intent(OUT) :: lnd_present
00461 logical, optional, intent(OUT) :: ice_present
00462 logical, optional, intent(OUT) :: ocn_present
00463 logical, optional, intent(OUT) :: rof_present
00464 logical, optional, intent(OUT) :: atm_prognostic
00465 logical, optional, intent(OUT) :: lnd_prognostic
00466 logical, optional, intent(OUT) :: ice_prognostic
00467 logical, optional, intent(OUT) :: ocn_prognostic
00468 logical, optional, intent(OUT) :: ocnrof_prognostic
00469 logical, optional, intent(OUT) :: samegrid
00470 integer(SHR_KIND_IN),optional, intent(OUT) :: info_debug
00471
00472
00473
00474
00475 character(len=*), parameter :: subname = '(shr_inputInfo_initGetData) '
00476 integer, parameter :: aqua_perpetual_ymd = 321
00477
00478
00479
00480 if ( present(aqua_planet) ) aqua_planet = CCSMInit%aqua_planet
00481 if ( present(single_column) ) single_column = CCSMInit%single_column
00482 if ( present(scmlat) ) scmlat = CCSMInit%scmlat
00483 if ( present(scmlon) ) scmlon = CCSMInit%scmlon
00484 if ( present(atm_adiabatic) ) atm_adiabatic = CCSMInit%atm_adiabatic
00485 if ( present(atm_ideal_phys) ) atm_ideal_phys = CCSMInit%atm_ideal_phys
00486 if ( present(start_type) ) start_type = CCSMInit%start_type
00487 if ( present(restart_pfile) ) restart_pfile = CCSMInit%restart_pfile
00488 if ( present(restart_file) ) restart_file = CCSMInit%restart_file
00489 if ( present(case_name) ) case_name = CCSMInit%case_name
00490 if ( present(case_desc) ) case_desc = CCSMInit%case_desc
00491 if ( present(version) ) version = CCSMInit%version
00492 if ( present(username) ) username = CCSMInit%username
00493 if ( present(hostname) ) hostname = CCSMInit%hostname
00494 if ( present(logFilePostFix) ) logFilePostFix = CCSMInit%logFilePostFix
00495 if ( present(outPathRoot) ) outPathRoot = CCSMInit%outPathRoot
00496
00497 if ( present(brnch_retain_casename) ) &
00498 brnch_retain_casename = CCSMInit%brnch_retain_casename
00499
00500
00501 if ( present(perpetual_run) )then
00502 if ( .not. present(perpetual_ymd) )then
00503 call shr_sys_abort( subname//':: asking for perpetual_run but not '//&
00504 'perpetual_ymd' )
00505 end if
00506 if ( CCSMInit%aqua_planet )then
00507 perpetual_run = .true.
00508 perpetual_ymd = aqua_perpetual_ymd
00509 else
00510 perpetual_run = .false.
00511 perpetual_ymd = 0
00512 end if
00513 end if
00514
00515 if ( present(dead_comps) ) dead_comps = CCSMInit%dead_comps
00516 if ( present(lnd_present) ) lnd_present = CCSMInit%lnd_present
00517 if ( present(ice_present) ) ice_present = CCSMInit%ice_present
00518 if ( present(ocn_present) ) ocn_present = CCSMInit%ocn_present
00519 if ( present(rof_present) ) rof_present = CCSMInit%rof_present
00520 if ( present(atm_prognostic) ) atm_prognostic = CCSMInit%atm_prognostic
00521 if ( present(lnd_prognostic) ) lnd_prognostic = CCSMInit%lnd_prognostic
00522 if ( present(ice_prognostic) ) ice_prognostic = CCSMInit%ice_prognostic
00523 if ( present(ocn_prognostic) ) ocn_prognostic = CCSMInit%ocn_prognostic
00524 if ( present(ocnrof_prognostic)) ocnrof_prognostic= CCSMInit%ocnrof_prognostic
00525 if ( present(samegrid) ) samegrid = CCSMInit%samegrid
00526 if ( present(info_debug) ) info_debug = CCSMInit%info_debug
00527
00528 END SUBROUTINE shr_inputInfo_initGetData
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540 SUBROUTINE shr_inputInfo_initPutData( CCSMInit, case_name, case_desc, &
00541 version, username, hostname, &
00542 start_type, atm_adiabatic, &
00543 atm_ideal_phys, aqua_planet, &
00544 restart_file, restart_pfile, &
00545 restart_file_override, &
00546 brnch_retain_casename,single_column, &
00547 scmlat, scmlon, &
00548 logFilePostFix, outPathRoot, &
00549 lnd_present, ice_present, ocn_present, rof_present, &
00550 atm_prognostic, lnd_prognostic, ice_prognostic, &
00551 ocn_prognostic, ocnrof_prognostic, &
00552 dead_comps, samegrid, info_debug)
00553
00554 implicit none
00555
00556
00557
00558 type(shr_inputInfo_InitType), intent(INOUT) :: CCSMInit
00559 character(len=*), intent(IN), optional :: case_name
00560 character(len=*), intent(IN), optional :: case_desc
00561 character(len=*), intent(IN), optional :: version
00562 character(len=*), intent(IN), optional :: username
00563 character(len=*), intent(IN), optional :: hostname
00564 character(len=*), intent(IN), optional :: start_type
00565 character(len=*), intent(IN), optional :: restart_file
00566 character(len=*), intent(IN), optional :: restart_pfile
00567 character(len=*), intent(IN), optional :: logFilePostFix
00568 character(len=*), intent(IN), optional :: outPathRoot
00569
00570 character(len=*), intent(IN), optional :: restart_file_override
00571 logical, intent(IN), optional :: atm_adiabatic
00572 logical, intent(IN), optional :: atm_ideal_phys
00573 logical, intent(IN), optional :: aqua_planet
00574 logical, intent(IN), optional :: single_column
00575 real(SHR_KIND_R8),intent(IN), optional :: scmlat
00576 real(SHR_KIND_R8),intent(IN), optional :: scmlon
00577
00578 logical, intent(IN), optional :: brnch_retain_casename
00579
00580 logical, intent(IN), optional :: dead_comps
00581 logical, intent(IN), optional :: lnd_present
00582 logical, intent(IN), optional :: ice_present
00583 logical, intent(IN), optional :: ocn_present
00584 logical, intent(IN), optional :: samegrid
00585 logical, intent(IN), optional :: rof_present
00586 logical, intent(IN), optional :: atm_prognostic
00587 logical, intent(IN), optional :: lnd_prognostic
00588 logical, intent(IN), optional :: ice_prognostic
00589 logical, intent(IN), optional :: ocn_prognostic
00590 logical, intent(IN), optional :: ocnrof_prognostic
00591 integer(SHR_KIND_IN),intent(IN),optional :: info_debug
00592
00593
00594
00595
00596 character(len=*), parameter :: subname = '(shr_inputInfo_initPutData) '
00597
00598
00599
00600
00601
00602 if ( present(case_name) ) CCSMInit%case_name = case_name
00603 if ( present(case_desc) ) CCSMInit%case_desc = case_desc
00604 if ( present(version) ) CCSMInit%version = version
00605 if ( present(username) ) CCSMInit%username = username
00606 if ( present(hostname) ) CCSMInit%hostname = hostname
00607 if ( present(start_type) ) CCSMInit%start_type = start_type
00608 if ( present(atm_adiabatic) ) CCSMInit%atm_adiabatic = atm_adiabatic
00609 if ( present(atm_ideal_phys) ) CCSMInit%atm_ideal_phys = atm_ideal_phys
00610 if ( present(aqua_planet) ) CCSMInit%aqua_planet = aqua_planet
00611 if ( present(single_column) ) CCSMInit%single_column = single_column
00612 if ( present(scmlat) ) CCSMInit%scmlat = scmlat
00613 if ( present(scmlon) ) CCSMInit%scmlon = scmlon
00614 if ( present(restart_file) ) CCSMInit%restart_file = restart_file
00615 if ( present(restart_pfile) ) CCSMInit%restart_pfile = restart_pfile
00616 if ( present(logFilePostFix) ) CCSMInit%logFilePostFix = logFilePostFix
00617 if ( present(outPathRoot) ) CCSMInit%outPathRoot = outPathRoot
00618
00619 if ( present(restart_file_override)) CCSMInit%restart_file_override = restart_file_override
00620 if ( present(brnch_retain_casename)) CCSMInit%brnch_retain_casename = brnch_retain_casename
00621
00622 if ( present(dead_comps) ) CCSMInit%dead_comps = dead_comps
00623 if ( present(lnd_present) ) CCSMInit%lnd_present = lnd_present
00624 if ( present(ice_present) ) CCSMInit%ice_present = ice_present
00625 if ( present(ocn_present) ) CCSMInit%ocn_present = ocn_present
00626 if ( present(rof_present) ) CCSMInit%rof_present = rof_present
00627 if ( present(atm_prognostic) ) CCSMInit%atm_prognostic = atm_prognostic
00628 if ( present(lnd_prognostic) ) CCSMInit%lnd_prognostic = lnd_prognostic
00629 if ( present(ice_prognostic) ) CCSMInit%ice_prognostic = ice_prognostic
00630 if ( present(ocn_prognostic) ) CCSMInit%ocn_prognostic = ocn_prognostic
00631 if ( present(ocnrof_prognostic)) CCSMInit%ocnrof_prognostic= ocnrof_prognostic
00632 if ( present(samegrid) ) CCSMInit%samegrid = samegrid
00633 if ( present(info_debug) ) CCSMInit%info_debug = info_debug
00634
00635 END SUBROUTINE shr_inputInfo_initPutData
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649 SUBROUTINE shr_inputInfo_initRead( NLFilename, LogPrint, mpicom, masterTask, &
00650 CCSMInitOut )
00651
00652
00653
00654 USE shr_file_mod, ONLY : shr_file_getUnit, shr_file_freeUnit
00655 USE shr_string_mod, ONLY : shr_string_toUpper, shr_string_listAppend
00656 USE shr_mpi_mod, ONLY : shr_mpi_bcast
00657
00658 implicit none
00659
00660
00661
00662 character(len=*), intent(IN) :: NLFilename
00663 logical, intent(IN) :: LogPrint
00664 integer, optional, intent(IN) :: mpicom
00665 logical, optional, intent(IN) :: MasterTask
00666 type(shr_inputInfo_InitType), intent(INOUT) :: CCSMInitOut
00667
00668
00669
00670
00671 character(len=*), parameter :: subname = '(shr_inputInfo_initRead) '
00672 logical :: MasterTask2
00673 character(len=SHR_KIND_CL) :: case_desc
00674 character(SHR_KIND_CS) :: case_name
00675 character(SHR_KIND_CL) :: version
00676 character(SHR_KIND_CL) :: username
00677 character(SHR_KIND_CL) :: hostname
00678 character(SHR_KIND_CL) :: start_type
00679 character(SHR_KIND_CL) :: restart_pfile
00680 character(SHR_KIND_CL) :: restart_file
00681
00682
00683 character(SHR_KIND_CL) :: restart_file_override
00684 logical :: aqua_planet
00685 logical :: single_column
00686 real (SHR_KIND_R8) :: scmlat
00687 real (SHR_KIND_R8) :: scmlon
00688 logical :: atm_adiabatic
00689 logical :: atm_ideal_phys
00690 logical :: brnch_retain_casename
00691 character(len=SHR_KIND_CS) :: logFilePostFix
00692 character(len=SHR_KIND_CL) :: outPathRoot
00693 integer :: rcode
00694 integer :: ierr
00695 integer :: unitn
00696 integer(SHR_KIND_IN) :: info_debug
00697
00698 namelist /ccsm_inparm/ &
00699 case_desc, case_name, version, username, &
00700 hostname, start_type, brnch_retain_casename, &
00701 atm_adiabatic, atm_ideal_phys, aqua_planet, &
00702 restart_pfile, restart_file, info_debug, &
00703 restart_file_override,single_column, scmlat, &
00704 scmlon, logFilePostFix, outPathRoot
00705
00706
00707
00708 if ( present(MasterTask) )then
00709 MasterTask2 = MasterTask
00710 else
00711 MasterTask2 = .true.
00712 end if
00713 if ( present(MasterTask) .and. .not. present(mpicom) )then
00714 call shr_sys_abort( subname//':: if MasterTask input, so must mpicom' )
00715 endif
00716 if ( .not. present(MasterTask) .and. present(mpicom) )then
00717 call shr_sys_abort( subname//':: if mpicom input, so must MasterTask' )
00718 endif
00719
00720
00721
00722
00723 case_desc = CCSMInitOut%case_desc
00724 case_name = CCSMInitOut%case_name
00725 version = CCSMInitOut%version
00726 username = CCSMInitOut%username
00727 hostname = CCSMInitOut%hostname
00728 start_type = CCSMInitOut%start_type
00729 atm_ideal_phys = CCSMInitOut%atm_ideal_phys
00730 atm_adiabatic = CCSMInitOut%atm_adiabatic
00731 aqua_planet = CCSMInitOut%aqua_planet
00732 single_column = CCSMInitOut%single_column
00733 scmlat = CCSMInitOut%scmlat
00734 scmlon = CCSMInitOut%scmlon
00735 restart_pfile = CCSMInitOut%restart_pfile
00736 restart_file = CCSMInitOut%restart_file
00737 restart_file_override = CCSMInitOut%restart_file_override
00738 brnch_retain_casename = CCSMInitOut%brnch_retain_casename
00739 logFilePostFix = CCSMInitOut%logFilePostFix
00740 outPathRoot = CCSMInitOut%outPathRoot
00741 info_debug = CCSMInitOut%info_debug
00742
00743
00744
00745
00746 if ( MasterTask2 )then
00747 unitn = shr_file_getUnit()
00748 if (s_loglev > 0) write(s_logunit,FAA) 'Read in ccsm_inparm namelist from: '//trim(NLFilename)
00749 open( unitn, file=trim(NLFilename), status='old' )
00750 ierr = 1
00751 do while( ierr /= 0 )
00752 read(unitn,nml=ccsm_inparm,iostat=ierr)
00753 if (ierr < 0) then
00754 call shr_sys_abort( subname//':: namelist read returns an'// &
00755 ' end of file or end of record condition' )
00756 end if
00757 end do
00758 close(unitn)
00759 call shr_file_freeUnit( unitn )
00760 end if
00761
00762
00763
00764
00765 if ( present(mpicom) )then
00766 call shr_mpi_bcast( case_desc, MPICom )
00767 call shr_mpi_bcast( case_name, MPICom )
00768 call shr_mpi_bcast( version, MPICom )
00769 call shr_mpi_bcast( username, MPICom )
00770 call shr_mpi_bcast( hostname, MPICom )
00771 call shr_mpi_bcast( start_type, MPICom )
00772 call shr_mpi_bcast( atm_ideal_phys, MPICom )
00773 call shr_mpi_bcast( atm_adiabatic, MPICom )
00774 call shr_mpi_bcast( aqua_planet, MPICom )
00775 call shr_mpi_bcast( single_column, MPICom )
00776 call shr_mpi_bcast( scmlat, MPICom )
00777 call shr_mpi_bcast( scmlon, MPICom )
00778 call shr_mpi_bcast( restart_pfile, MPICom )
00779 call shr_mpi_bcast( restart_file, MPICom )
00780 call shr_mpi_bcast( restart_file_override, MPICom )
00781 call shr_mpi_bcast( brnch_retain_casename, MPICom )
00782 call shr_mpi_bcast( logFilePostFix, MPICom )
00783 call shr_mpi_bcast( outPathRoot, MPICom )
00784 call shr_mpi_bcast( info_debug, MPICom )
00785 end if
00786
00787
00788
00789
00790 CCSMInitOut%case_desc = case_desc
00791 CCSMInitOut%case_name = case_name
00792 CCSMInitOut%version = version
00793 CCSMInitOut%username = username
00794 CCSMInitOut%hostname = hostname
00795 CCSMInitOut%start_type = start_type
00796 CCSMInitOut%atm_ideal_phys = atm_ideal_phys
00797 CCSMInitOut%atm_adiabatic = atm_adiabatic
00798 CCSMInitOut%aqua_planet = aqua_planet
00799 CCSMInitOut%single_column = single_column
00800 CCSMInitOut%scmlat = scmlat
00801 CCSMInitOut%scmlon = scmlon
00802 CCSMInitOut%restart_pfile = restart_pfile
00803 CCSMInitOut%restart_file = restart_file
00804 CCSMInitOut%restart_file_override = restart_file_override
00805 CCSMInitOut%brnch_retain_casename = brnch_retain_casename
00806 CCSMInitOut%logFilePostFix = logFilePostFix
00807 CCSMInitOut%outPathRoot = outPathRoot
00808 CCSMInitOut%info_debug = info_debug
00809
00810 if (CCSMInitOut%aqua_planet) then
00811 CCSMInitOut%lnd_present = .false.
00812 CCSMInitOut%ice_present = .false.
00813 CCSMInitOut%ocn_present = .true.
00814 end if
00815 if (CCSMInitOut%atm_adiabatic .or. CCSMInitOut%atm_ideal_phys) then
00816 CCSMInitOut%lnd_present = .false.
00817 CCSMInitOut%ice_present = .false.
00818 CCSMInitOut%ocn_present = .false.
00819 end if
00820
00821
00822
00823
00824 if ( len_trim(CCSMInitOut%restart_pfile) == 0 )then
00825 CCSMInitOut%restart_pfile = 'rpointer' //'.drv'
00826 end if
00827
00828
00829
00830
00831
00832 if ( shr_inputInfo_initIsBranch( CCSMInitOut ) .and. &
00833 (.not. CCSMInitOut%brnch_retain_casename) )then
00834 call shr_string_listAppend( CCSMInitOut%restart_file_override, &
00835 "case_name" )
00836 end if
00837
00838
00839 call shr_inputInfo_initCheck( CCSMInitOut )
00840 if ( LogPrint) call shr_inputInfo_initPrint( CCSMInitOut )
00841
00842 END SUBROUTINE shr_inputInfo_initRead
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855 logical FUNCTION shr_inputInfo_initIsStartup( CCSMInit )
00856
00857 implicit none
00858
00859
00860
00861 type(shr_inputInfo_InitType), intent(IN) :: CCSMInit
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872 if ( trim(CCSMInit%start_type) == shr_inputInfo_start_type_start )then
00873 shr_inputInfo_initIsStartup = .true.
00874 else
00875 shr_inputInfo_initIsStartup = .false.
00876 end if
00877
00878 END FUNCTION shr_inputInfo_initIsStartup
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891 logical FUNCTION shr_inputInfo_initIsRestart( CCSMInit )
00892
00893 implicit none
00894
00895
00896
00897 type(shr_inputInfo_InitType), intent(IN) :: CCSMInit
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908 shr_inputInfo_initIsRestart = .not. shr_inputInfo_initIsStartup( CCSMInit )
00909
00910 END FUNCTION shr_inputInfo_initIsRestart
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923 logical FUNCTION shr_inputInfo_initIsContinue( CCSMInit )
00924
00925 implicit none
00926
00927
00928
00929 type(shr_inputInfo_InitType), intent(IN) :: CCSMInit
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940 if ( trim(CCSMInit%start_type) == shr_inputInfo_start_type_cont )then
00941 shr_inputInfo_initIsContinue = .true.
00942 else
00943 shr_inputInfo_initIsContinue = .false.
00944 end if
00945
00946 END FUNCTION shr_inputInfo_initIsContinue
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959 logical FUNCTION shr_inputInfo_initIsBranch( CCSMInit )
00960
00961 implicit none
00962
00963
00964
00965 type(shr_inputInfo_InitType), intent(IN) :: CCSMInit
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976 if ( trim(CCSMInit%start_type) == shr_inputInfo_start_type_brnch )then
00977 shr_inputInfo_initIsBranch = .true.
00978 else
00979 shr_inputInfo_initIsBranch = .false.
00980 end if
00981
00982 END FUNCTION shr_inputInfo_initIsBranch
00983
00984
00985
00986
00987
00988
00989
00990
00991
00992
00993 logical FUNCTION shr_inputInfo_initIsSame( CCSMInit, CCSMInit2 )
00994
00995 implicit none
00996
00997
00998 type(shr_inputInfo_InitType), intent(IN) :: CCSMInit
00999 type(shr_inputInfo_InitType), intent(IN) :: CCSMInit2
01000
01001
01002
01003
01004
01005
01006
01007 shr_inputInfo_initIsSame = .false.
01008 if ( CCSMInit%start_type /= CCSMInit2%start_type ) return
01009 if ( CCSMInit%case_desc /= CCSMInit2%case_desc ) return
01010 if ( CCSMInit%case_name /= CCSMInit2%case_name ) return
01011 if ( CCSMInit%version /= CCSMInit2%version ) return
01012 if ( CCSMInit%username /= CCSMInit2%username ) return
01013 if ( CCSMInit%hostname /= CCSMInit2%hostname ) return
01014 if ( CCSMInit%atm_adiabatic .neqv. CCSMInit2%atm_adiabatic ) return
01015 if ( CCSMInit%atm_ideal_phys .neqv. CCSMInit2%atm_ideal_phys ) return
01016 if ( CCSMInit%aqua_planet .neqv. CCSMInit2%aqua_planet ) return
01017 if ( CCSMInit%restart_pfile /= CCSMInit2%restart_pfile ) return
01018 if ( CCSMInit%restart_file /= CCSMInit2%restart_file ) return
01019 if ( CCSMInit%restart_file_override /= CCSMInit2%restart_file_override ) return
01020 if ( CCSMInit%logFilePostFix /= CCSMInit2%logFilePostFix ) return
01021 if ( CCSMInit%outPathRoot /= CCSMInit2%outPathRoot ) return
01022 if ( CCSMInit%brnch_retain_casename .neqv. CCSMInit2%brnch_retain_casename ) return
01023 shr_inputInfo_initIsSame = .true.
01024 return
01025 END FUNCTION shr_inputInfo_initIsSame
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039 SUBROUTINE shr_inputInfo_initRestRead( restart_file, MPICom, MasterTask, &
01040 CCSMInitOut )
01041
01042
01043
01044 use netcdf
01045 use shr_ncio_mod, only: shr_ncio_descripRead, shr_ncio_descripName, &
01046 shr_ncio_descripGetString, &
01047 shr_ncio_descripGetRealR8, &
01048 shr_ncio_descripGetInteger, &
01049 shr_ncio_descripGetLogical
01050 use shr_string_mod, only: shr_string_listGetIndexF
01051
01052 implicit none
01053
01054
01055
01056 character(len=SHR_KIND_CL), intent(IN) :: restart_file
01057 integer, optional, intent(IN) :: MPICom
01058 logical, optional, intent(IN) :: MasterTask
01059 type(shr_inputInfo_InitType), intent(INOUT) :: CCSMInitOut
01060
01061
01062
01063
01064 character(len=*), parameter :: subname = "(shr_inputInfo_initRestRead) "
01065 logical :: MasterTask2
01066 integer :: i
01067 integer :: list
01068 integer :: ncId
01069 logical :: exists
01070
01071
01072
01073
01074 if ( present(MasterTask) )then
01075 MasterTask2 = MasterTask
01076 else
01077 MasterTask2 = .true.
01078 end if
01079 if ( present(MasterTask) .and. .not. present(mpicom) )then
01080 call shr_sys_abort( subname//':: if MasterTask input, so must mpicom' )
01081 endif
01082 if ( .not. present(MasterTask) .and. present(mpicom) )then
01083 call shr_sys_abort( subname//':: if mpicom input, so must MasterTask' )
01084 endif
01085
01086 if ( .not. shr_inputInfo_initIsRestart( CCSMInitOut ) ) return
01087 if ( shr_inputInfo_initIsBranch( CCSMInitOut ) .and. len_trim(restart_file) == 0 &
01088 )then
01089 call shr_sys_abort( subname//': on a branch run, restart_file MUST be '// &
01090 'set on namelist' )
01091 end if
01092
01093 call shr_ncio_open( restart_file, MasterTask2, FileType=prefix//"restart_file", &
01094 ncId=ncId, exists=exists )
01095 if ( present(MPICom) )then
01096 call shr_ncio_descripRead( ncId, NVars, prefix, MPICom, MasterTask2, &
01097 var=CCSMInitOut%var )
01098 else
01099 call shr_ncio_descripRead( ncId, NVars, prefix, var=CCSMInitOut%var )
01100 end if
01101 call shr_ncio_close( ncId, MasterTask2, type=prefix//"restart_file", &
01102 NCFileName=restart_file )
01103
01104
01105
01106
01107
01108 do i = 1, NVars
01109 if ( trim(shr_ncio_descripName(CCSMInitOut%var(i))) == "case_desc" )then
01110 list = shr_string_listGetIndexF( CCSMInitOut%restart_file_override, &
01111 trim(shr_ncio_descripName(CCSMInitOut%var(i)) ) )
01112 if ( list == 0 ) CCSMInitOut%case_desc = &
01113 shr_ncio_descripGetString(CCSMInitOut%var(i))
01114 else if ( trim(shr_ncio_descripName(CCSMInitOut%var(i))) == "case_name" )then
01115 list = shr_string_listGetIndexF( CCSMInitOut%restart_file_override, &
01116 trim(shr_ncio_descripName(CCSMInitOut%var(i)) ) )
01117 if ( shr_inputInfo_initIsBranch( CCSMInitOut ) .and. &
01118 (.not. CCSMInitOut%brnch_retain_casename) )then
01119 if ( trim(CCSMInitOut%case_name) == &
01120 trim(shr_ncio_descripGetString(CCSMInitOut%var(i))) )then
01121 call shr_sys_abort( subname//': Branch and case_name same as '// &
01122 'on restart_file and brnch_retain_casename not set' )
01123 end if
01124 end if
01125 if ( list == 0 ) CCSMInitOut%case_name = &
01126 shr_ncio_descripGetString(CCSMInitOut%var(i))
01127 else if ( trim(shr_ncio_descripName(CCSMInitOut%var(i))) == "version" )then
01128 list = shr_string_listGetIndexF( CCSMInitOut%restart_file_override, &
01129 trim(shr_ncio_descripName(CCSMInitOut%var(i)) ) )
01130 if ( list == 0 ) CCSMInitOut%version = &
01131 shr_ncio_descripGetString(CCSMInitOut%var(i))
01132 else if ( trim(shr_ncio_descripName(CCSMInitOut%var(i))) == "username" )then
01133 list = shr_string_listGetIndexF( CCSMInitOut%restart_file_override, &
01134 trim(shr_ncio_descripName(CCSMInitOut%var(i)) ) )
01135 if ( list == 0 ) CCSMInitOut%username = &
01136 shr_ncio_descripGetString(CCSMInitOut%var(i))
01137 else if ( trim(shr_ncio_descripName(CCSMInitOut%var(i))) == "hostname" )then
01138 list = shr_string_listGetIndexF( CCSMInitOut%restart_file_override, &
01139 trim(shr_ncio_descripName(CCSMInitOut%var(i)) ) )
01140 if ( list == 0 ) CCSMInitOut%hostname = &
01141 shr_ncio_descripGetString(CCSMInitOut%var(i))
01142 else if ( trim(shr_ncio_descripName(CCSMInitOut%var(i))) == "atm_adiabatic" )then
01143 list = shr_string_listGetIndexF( CCSMInitOut%restart_file_override, &
01144 trim(shr_ncio_descripName(CCSMInitOut%var(i)) ) )
01145 if ( list == 0 ) CCSMInitOut%atm_adiabatic = &
01146 shr_ncio_descripGetLogical(CCSMInitOut%var(i))
01147 else if ( trim(shr_ncio_descripName(CCSMInitOut%var(i))) == "atm_ideal_phys" )then
01148 list = shr_string_listGetIndexF( CCSMInitOut%restart_file_override, &
01149 trim(shr_ncio_descripName(CCSMInitOut%var(i)) ) )
01150 if ( list == 0 ) CCSMInitOut%atm_ideal_phys = &
01151 shr_ncio_descripGetLogical(CCSMInitOut%var(i))
01152 else if ( trim(shr_ncio_descripName(CCSMInitOut%var(i))) == "aqua_planet" )then
01153 list = shr_string_listGetIndexF( CCSMInitOut%restart_file_override, &
01154 trim(shr_ncio_descripName(CCSMInitOut%var(i)) ) )
01155 if ( list == 0 ) CCSMInitOut%aqua_planet = &
01156 shr_ncio_descripGetLogical(CCSMInitOut%var(i))
01157 else if ( trim(shr_ncio_descripName(CCSMInitOut%var(i))) == "single_column" )then
01158 list = shr_string_listGetIndexF( CCSMInitOut%restart_file_override, &
01159 trim(shr_ncio_descripName(CCSMInitOut%var(i)) ) )
01160 if ( list == 0 ) CCSMInitOut%single_column = &
01161 shr_ncio_descripGetLogical(CCSMInitOut%var(i))
01162 else if ( trim(shr_ncio_descripName(CCSMInitOut%var(i))) == "scmlat" )then
01163 list = shr_string_listGetIndexF( CCSMInitOut%restart_file_override, &
01164 trim(shr_ncio_descripName(CCSMInitOut%var(i)) ) )
01165 if ( list == 0 ) CCSMInitOut%scmlat = &
01166 shr_ncio_descripGetRealR8(CCSMInitOut%var(i))
01167 else if ( trim(shr_ncio_descripName(CCSMInitOut%var(i))) == "scmlon" )then
01168 list = shr_string_listGetIndexF( CCSMInitOut%restart_file_override, &
01169 trim(shr_ncio_descripName(CCSMInitOut%var(i)) ) )
01170 if ( list == 0 ) CCSMInitOut%scmlon = &
01171 shr_ncio_descripGetRealR8(CCSMInitOut%var(i))
01172 else
01173 call shr_sys_abort( subname//': unrecognized variable: '// &
01174 trim(shr_ncio_descripName(CCSMInitOut%var(i))) )
01175 end if
01176 end do
01177
01178 call shr_inputInfo_initCheck( CCSMInitOut )
01179
01180 END SUBROUTINE shr_inputInfo_initRestRead
01181
01182
01183
01184
01185
01186
01187
01188
01189
01190
01191
01192
01193 SUBROUTINE shr_inputInfo_initRestWrite( restart_file, MPICom, MasterTask, &
01194 CCSMInit )
01195
01196 use netcdf
01197 use shr_ncio_mod, only: shr_ncio_descripWrite, shr_ncio_descripPutData, &
01198 shr_ncio_descripName
01199
01200 implicit none
01201
01202
01203
01204 character(len=SHR_KIND_CL), intent(IN) :: restart_file
01205 integer, optional, intent(IN) :: MPICom
01206 logical, optional, intent(IN) :: MasterTask
01207 type(shr_inputInfo_InitType), intent(INOUT) :: CCSMInit
01208
01209
01210
01211
01212 character(len=*), parameter :: subname = "(shr_inputInfo_initRestWrite) "
01213 logical :: MasterTask2
01214 logical :: exists
01215 integer :: ncId
01216 integer :: i
01217
01218
01219
01220
01221
01222 if ( present(MasterTask) )then
01223 MasterTask2 = MasterTask
01224 else
01225 MasterTask2 = .true.
01226 end if
01227 if ( present(MasterTask) .and. .not. present(mpicom) )then
01228 call shr_sys_abort( subname//':: if MasterTask input, so must mpicom' )
01229 endif
01230 if ( .not. present(MasterTask) .and. present(mpicom) )then
01231 call shr_sys_abort( subname//':: if mpicom input, so must MasterTask' )
01232 endif
01233
01234
01235
01236 do i = 1, NVars
01237 if ( trim(shr_ncio_descripName( CCSMInit%var(i) ) ) == "atm_adiabatic" )then
01238 call shr_ncio_descripPutData( CCSMInit%var(i), "atm_adiabatic", &
01239 LogicalData=CCSMInit%atm_adiabatic )
01240 else if ( trim(shr_ncio_descripName( CCSMInit%var(i) ) ) == "atm_ideal_phys" &
01241 )then
01242 call shr_ncio_descripPutData( CCSMInit%var(i), "atm_ideal_phys", &
01243 LogicalData=CCSMInit%atm_ideal_phys )
01244 else if ( trim(shr_ncio_descripName( CCSMInit%var(i) ) ) == "aqua_planet" )then
01245 call shr_ncio_descripPutData( CCSMInit%var(i), "aqua_planet", &
01246 LogicalData=CCSMInit%aqua_planet )
01247 else if ( trim(shr_ncio_descripName( CCSMInit%var(i) ) ) == "single_column" )then
01248 call shr_ncio_descripPutData( CCSMInit%var(i), "single_column", &
01249 LogicalData=CCSMInit%single_column )
01250 else if ( trim(shr_ncio_descripName( CCSMInit%var(i) ) ) == "scmlat" )then
01251 call shr_ncio_descripPutData( CCSMInit%var(i), "scmlat", &
01252 RealR8Data=CCSMInit%scmlat )
01253 else if ( trim(shr_ncio_descripName( CCSMInit%var(i) ) ) == "scmlon" )then
01254 call shr_ncio_descripPutData( CCSMInit%var(i), "scmlon", &
01255 RealR8Data=CCSMInit%scmlon )
01256 else if ( trim(shr_ncio_descripName( CCSMInit%var(i) ) ) == "case_desc" )then
01257 call shr_ncio_descripPutData( CCSMInit%var(i), "case_desc", &
01258 StringData=CCSMInit%case_desc )
01259 else if ( trim(shr_ncio_descripName( CCSMInit%var(i) ) ) == "case_name" )then
01260 call shr_ncio_descripPutData( CCSMInit%var(i), "case_name", &
01261 StringData=CCSMInit%case_name )
01262 else if ( trim(shr_ncio_descripName( CCSMInit%var(i) ) ) == "version" )then
01263 call shr_ncio_descripPutData( CCSMInit%var(i), "version", &
01264 StringData=CCSMInit%version )
01265 else if ( trim(shr_ncio_descripName( CCSMInit%var(i) ) ) == "username" )then
01266 call shr_ncio_descripPutData( CCSMInit%var(i), "username", &
01267 StringData=CCSMInit%username )
01268 else if ( trim(shr_ncio_descripName( CCSMInit%var(i) ) ) == "hostname" )then
01269 call shr_ncio_descripPutData( CCSMInit%var(i), "hostname", &
01270 StringData=CCSMInit%hostname )
01271 else
01272 call shr_sys_abort( subname//': unknown variable name: '// &
01273 trim(shr_ncio_descripName( CCSMInit%var(i) ) ) )
01274 end if
01275 end do
01276
01277
01278 call shr_ncio_open( NCFileName=restart_file, MasterTask=masterTask2, &
01279 FileType=trim(prefix)//"restart_file", &
01280 ncId=ncId, exists=exists, writing=.true., clobber=.true. )
01281 exists = .false.
01282 if ( present(MPICom) )then
01283 call shr_ncio_descripWrite( ncId, NVars, prefix, mpicom, MasterTask2, &
01284 exists=exists, var=CCSMInit%var )
01285 else
01286 call shr_ncio_descripWrite( ncId, NVars, prefix, exists=exists, &
01287 var=CCSMInit%var )
01288 end if
01289 call shr_ncio_close( ncId, MasterTask2, type=prefix//"restart_file", &
01290 NCFileName=restart_file )
01291
01292 END SUBROUTINE shr_inputInfo_initRestWrite
01293
01294
01295
01296
01297
01298
01299
01300
01301
01302
01303
01304
01305 SUBROUTINE shr_inputInfo_initRPointerRead( MPICom, MasterTask, CCSMInit, &
01306 restart_file )
01307
01308
01309 USE shr_file_mod, ONLY : shr_file_getUnit, shr_file_freeUnit, shr_file_get
01310 USE shr_mpi_mod, ONLY : shr_mpi_bcast
01311
01312 implicit none
01313
01314
01315
01316 integer, optional, intent(IN) :: MPICom
01317 logical, optional, intent(IN) :: MasterTask
01318 type(shr_inputInfo_InitType), intent(INOUT) :: CCSMInit
01319 character(len=SHR_KIND_CL), intent(OUT) :: restart_file
01320
01321
01322
01323
01324 character(len=*), parameter :: subname = "(shr_inputInfo_initRPointerRead) "
01325 integer :: rUnit
01326 logical :: MasterTask2
01327 character(len=SHR_KIND_CL) :: rest_file_archive
01328 integer :: ierr
01329 integer :: i
01330
01331
01332
01333
01334
01335 if ( present(MasterTask) )then
01336 MasterTask2 = MasterTask
01337 else
01338 MasterTask2 = .true.
01339 end if
01340 if ( present(MasterTask) .and. .not. present(mpicom) )then
01341 call shr_sys_abort( subname//':: if MasterTask input, so must mpicom' )
01342 endif
01343 if ( .not. present(MasterTask) .and. present(mpicom) )then
01344 call shr_sys_abort( subname//':: if mpicom input, so must MasterTask' )
01345 endif
01346
01347 if ( .not. shr_inputInfo_initIsRestart( CCSMInit ) )then
01348 call shr_sys_abort( subname//":: can only read RPointer file if "// &
01349 "restart or continue" )
01350 end if
01351
01352
01353 if ( shr_inputInfo_initIsContinue( CCSMInit ) )then
01354
01355 if ( MasterTask2 )then
01356 rUnit = shr_file_getUnit()
01357 if (s_loglev > 0) write(s_logunit,FAA) 'Read ccsm driver restart pointer file: '// &
01358 trim(CCSMInit%restart_pfile)
01359 open(rUnit, file=CCSMInit%restart_pfile, form='FORMATTED', status='old')
01360 read(rUnit,'(a)') rest_file_archive
01361 close(rUnit)
01362 call shr_file_freeUnit( rUnit )
01363 end if
01364
01365 if ( present(MPICom) ) call shr_mpi_bcast( rest_file_archive, MPICom )
01366 else
01367
01368 rest_file_archive = CCSMInit%restart_file
01369 end if
01370 CCSMInit%restart_file = rest_file_archive
01371
01372
01373 i = index( rest_file_archive, "/", back=.true. )
01374 if ( i > 0 )then
01375 restart_file = rest_file_archive(i+1:len_trim(rest_file_archive))
01376 else
01377 restart_file = rest_file_archive
01378 end if
01379 if ( MasterTask2 ) call shr_file_get( ierr, restart_file, rest_file_archive )
01380
01381 END SUBROUTINE shr_inputInfo_initRPointerRead
01382
01383
01384
01385
01386
01387
01388
01389
01390
01391
01392
01393
01394 SUBROUTINE shr_inputInfo_initRPointerWrite( ymd, tod, MPICom, MasterTask, &
01395 FileType, CCSMInit, restart_file )
01396
01397
01398 use shr_file_mod, only: shr_file_getUnit, shr_file_freeUnit, shr_file_get
01399
01400 implicit none
01401
01402
01403
01404 integer, intent(IN) :: ymd
01405 integer, intent(IN) :: tod
01406 integer, optional, intent(IN) :: MPICom
01407 logical, optional, intent(IN) :: MasterTask
01408 character(len=*), optional, intent(IN) :: FileType
01409 type(shr_inputInfo_InitType), intent(INOUT) :: CCSMInit
01410 character(len=SHR_KIND_CL), intent(OUT) :: restart_file
01411
01412
01413
01414
01415 character(len=*), parameter :: subname = "(shr_inputInfo_initRPointerWrite) "
01416 integer :: rUnit
01417 character(len=*), parameter :: filename_format =
01418 "(a,'.',a,'.', i4.4,'-',i2.2,'-',i2.2,'-',i5.5,'.nc')"
01419 character(len=SHR_KIND_CS) :: type
01420 logical :: MasterTask2
01421 integer :: ierr
01422 integer :: yr
01423 integer :: mon
01424 integer :: day
01425
01426
01427
01428
01429
01430 if ( present(MasterTask) )then
01431 MasterTask2 = MasterTask
01432 else
01433 MasterTask2 = .true.
01434 end if
01435 if ( present(FileType) )then
01436 type = trim(FileType)
01437 else
01438 type = "drv.r"
01439 end if
01440
01441
01442 yr = ymd / 10000
01443 mon = (ymd - yr*10000) / 100
01444 day = ymd - yr*10000 - mon*100
01445 write(restart_file,filename_format) trim(CCSMInit%case_name), trim(type), &
01446 yr, mon, day, tod
01447 CCSMInit%restart_file = restart_file
01448
01449 if ( MasterTask2 )then
01450 if (s_loglev > 0) write(s_logunit,FAA) 'Write ccsm driver restart pointer file: '// &
01451 trim(CCSMInit%restart_pfile)
01452 rUnit = shr_file_getUnit()
01453 open(rUnit, file=CCSMInit%restart_pfile, form='FORMATTED', &
01454 status='UNKNOWN')
01455 write(rUnit,'(a)') trim(restart_file)
01456 close(rUnit)
01457 call shr_file_freeUnit( rUnit )
01458 end if
01459
01460 END SUBROUTINE shr_inputInfo_initRPointerWrite
01461
01462
01463
01464
01465
01466
01467
01468
01469
01470
01471
01472
01473 subroutine shr_inputInfo_initCheck( CCSMInit )
01474
01475
01476
01477 use shr_string_mod, only: shr_string_listIntersect
01478
01479 implicit none
01480
01481
01482
01483 type(shr_inputInfo_InitType), intent(INOUT) :: CCSMInit
01484
01485
01486
01487
01488 character(len=*), parameter :: subname = '(shr_inputInfo_initCheck) '
01489
01490 character(len=SHR_KIND_CL) :: OverrideList
01491 integer :: lastchar
01492 integer :: rc
01493 character(len=*), parameter :: F00 = "('"//LogPrefix//"',A,I3,A)"
01494
01495
01496
01497
01498
01499 if (CCSMInit%case_name==' ') then
01500 call shr_sys_abort( subname//': variable case_name must be set')
01501 end if
01502
01503 if ( len_trim(CCSMInit%restart_file_override) > 0 )then
01504 call shr_string_listIntersect( &
01505 CCSMInit%restart_file_override,restartFileOverRideList, &
01506 OverRideList, rc)
01507 if ( trim(OverRideList) /= trim(CCSMInit%restart_file_override) )then
01508 write(s_logunit,FAA)'ERROR: the only values that can be overridden are: '// &
01509 trim(restartFileOverRideList)
01510 call shr_sys_abort( subname//': list of values to override ' // &
01511 'includes values that can NOT' &
01512 //" be overridden" )
01513 end if
01514 end if
01515
01516 lastchar = len(CCSMInit%case_name)
01517 if ( len_trim(CCSMInit%case_name) == 0) then
01518 call shr_sys_abort( subname//': variable case_name must be set, aborting')
01519 end if
01520 if (CCSMInit%case_name(lastchar:lastchar) /= ' ') then
01521 write(s_logunit,F00)'ERROR: case_name must not exceed ', len(CCSMInit%case_name)-1, &
01522 ' characters'
01523 call shr_sys_abort( subname//': variable case_name must be set, aborting')
01524 end if
01525
01526 if ( CCSMInit%atm_adiabatic .and. (CCSMInit%atm_ideal_phys .or. &
01527 CCSMInit%aqua_planet) )then
01528 call shr_sys_abort( subname//': only one of atm_adiabatic, ' // &
01529 'atm_ideal_phys or aqua_planet can be set' )
01530 end if
01531
01532 if ( len_trim(CCSMInit%restart_pfile) == 0 ) then
01533 call shr_sys_abort( subname//': restart_pfile must be set' )
01534 end if
01535
01536 if ( len_trim(CCSMInit%logFilePostFix) == 0 ) then
01537 call shr_sys_abort( subname//': logFilePostFix must be set to something not blank' )
01538 end if
01539
01540 if ( len_trim(CCSMInit%outPathRoot) == 0 ) then
01541 call shr_sys_abort( subname//': outPathRoot must be set' )
01542 end if
01543 if ( index(CCSMInit%outPathRoot,"/",back=.true.) /= &
01544 len_trim(CCSMInit%outPathRoot) ) then
01545 call shr_sys_abort( subname//': outPathRoot must end with a slash' )
01546 end if
01547
01548 if ( len_trim(CCSMInit%start_type) == 0 ) then
01549 call shr_sys_abort( subname//': variable start_type must be set')
01550 end if
01551 if ( (trim(CCSMInit%start_type) /= shr_inputInfo_start_type_start ) &
01552 .and. (trim(CCSMInit%start_type) /= shr_inputInfo_start_type_cont ) &
01553 .and. (trim(CCSMInit%start_type) /= shr_inputInfo_start_type_brnch) &
01554 ) then
01555 call shr_sys_abort( subname//': variable start_type can only be ' // &
01556 'set to:' // &
01557 shr_inputInfo_start_type_start//', '// &
01558 shr_inputInfo_start_type_cont//', or'// &
01559 shr_inputInfo_start_type_brnch )
01560 end if
01561
01562 END SUBROUTINE shr_inputInfo_initCheck
01563
01564
01565
01566
01567 END MODULE shr_inputInfo_mod