Subroutine vom_read_input
432 :
433 : !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
434 : !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
435 : !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
436 : !*-----PARAMETER READING FROM INPUT.PAR---------------------------------
437 :
438 : subroutine vom_read_input ()
439 : use vom_vegwat_mod
440 : implicit none
441 :
442 : INTEGER :: iostat
443 : CHARACTER*100 :: outputpath_tmp ! Temporary outputpath
444 : CHARACTER*100 :: inputpath_tmp ! Temporary inputpath
445 : LOGICAL :: change_in ! Change input true/false
446 : LOGICAL :: change_out ! Change output true/false
447 :
448 : ! * Definition of variable parameters
449 :
450 : namelist /inputpar/ i_alpha, i_cpccf, i_tcf, i_maxyear, &
451 : & i_testyear, i_ha, i_hd, i_toptf, &
452 : & i_toptstart, i_rlratio, i_mdtf, i_mqxtf, &
453 : & i_rrootm, i_rsurfmin, i_rsurf_, i_rootrad, &
454 : & i_prootmg, i_growthmax, i_incrcovg, &
455 : & i_incrjmax, i_incrlait, i_incrlaig, &
456 : & i_extcoeffg, i_extcoefft, i_trans_vegcov, &
457 : & i_firstyear,i_lastyear, i_write_h, i_read_pc,&
458 : & i_lai_function, i_no_veg, &
459 : & i_inputpath, i_outputpath, &
460 : & o_lambdagf, o_wsgexp, o_lambdatf, o_wstexp, &
461 : & o_cai, o_rtdepth, o_mdstore, o_rgdepth
462 :
463 : namelist /input2par/ i_lat, i_cz, i_cgs, i_zr, i_go, i_ksat, &
464 : & i_thetar, i_thetas, i_nvg, i_avg, i_delz
465 :
466 :
467 : call read_commandline(outputpath_tmp, inputpath_tmp, change_in, change_out)
468 :
469 : ! * Input of variable parameters from the parameter file
470 :
471 : open(kfile_namelist, FILE=sfile_namelist, STATUS='old', &
472 : & FORM='formatted', IOSTAT=iostat)
473 : if (iostat .eq. 0) then
474 : read(kfile_namelist, inputpar)
475 : read(kfile_namelist, input2par)
476 : endif
477 : close(kfile_namelist)
478 :
479 : !change input and/or outputpaths
480 : if(change_in .eqv. .True.) then
481 : i_inputpath = inputpath_tmp
482 : write(*,*) "Changed inputpath to:", i_inputpath
483 : end if
484 :
485 : if(change_out .eqv. .True.) then
486 : i_outputpath = outputpath_tmp
487 : write(*,*) "Changed outputpath to:", i_outputpath
488 : end if
489 :
490 :
491 :
492 : c_epsln = i_thetas - i_thetar ! epsilon, porosity see Reggiani (2000)
493 : i_mvg = 1.d0 - (1.d0 / i_nvg) ! van Genuchten soil parameter m
494 :
495 : c_maxday = i_maxyear * 365
496 : c_maxhour = c_maxday * 24
497 :
498 : ! * The file soilprofile.par contain information about thickness and
499 : ! soil properties in each soil layer, with the layer number in the
500 : ! first column.
501 :
502 : s_maxlayer = 0
503 :
504 : open(kfile_soilprofile, FILE=trim(adjustl(i_inputpath))// &
505 : trim(adjustl(sfile_soilprofile)), &
506 : & STATUS='old', IOSTAT=iostat)
507 : if (iostat .eq. 0) then
508 : read(kfile_soilprofile,*) s_maxlayer
509 : endif
510 : close(kfile_soilprofile)
511 :
512 : ! * number of soil layers s_maxlayer assuming same thickness everywhere
513 : if (s_maxlayer .eq. 0) then
514 :
515 : ! Check if i_cz is a multiple of i_delz
516 : ! Raise a warning and correct if this is not the case
517 : if ( abs( nint(i_cz / i_delz) - (i_cz / i_delz) ) .gt. 1.0d-6) then
518 : write(*,*) nint(i_cz / i_delz) , (i_cz / i_delz)
519 : write(*,*) "ERROR: i_cz must be a multiple of i_delz"
520 : write(*,*) " Please correct in vom_namelist and restart"
521 : stop
522 : end if
523 :
524 : ! Check if i_cz - i_zr is a multiple of i_delz
525 : ! Raise a warning and correct if this is not the case
526 : if ( abs(nint( (i_cz - i_zr) /i_delz) - ( (i_cz - i_zr) /i_delz) ) .gt. 1.0d-6) then
527 : write(*,*) "ERROR: i_cz-i_zr must be a multiple of i_delz"
528 : write(*,*) " Please correct in vom_namelist and restart"
529 : stop
530 : end if
531 :
532 : s_maxlayer = nint(i_cz / i_delz)
533 : end if
534 :
535 : return
536 : end subroutine vom_read_input