MOM6
mom_file_parser::read_param Interface Reference

Detailed Description

Definition at line 125 of file MOM_file_parser.F90.

Private functions

subroutine read_param_int (CS, varname, value, fail_if_missing)
 
subroutine read_param_real (CS, varname, value, fail_if_missing)
 
subroutine read_param_logical (CS, varname, value, fail_if_missing)
 
subroutine read_param_char (CS, varname, value, fail_if_missing)
 
subroutine read_param_char_array (CS, varname, value, fail_if_missing)
 
subroutine read_param_time (CS, varname, value, timeunit, fail_if_missing, date_format)
 
subroutine read_param_int_array (CS, varname, value, fail_if_missing)
 
subroutine read_param_real_array (CS, varname, value, fail_if_missing)
 

Functions and subroutines

◆ read_param_char()

subroutine mom_file_parser::read_param::read_param_char ( type(param_file_type), intent(in)  CS,
character(len=*), intent(in)  varname,
character(len=*), intent(inout)  value,
logical, intent(in), optional  fail_if_missing 
)
private

Definition at line 704 of file MOM_file_parser.F90.

704  type(param_file_type), intent(in) :: cs
705  character(len=*), intent(in) :: varname
706  character(len=*), intent(inout) :: value
707  logical, optional, intent(in) :: fail_if_missing
708 ! This subroutine determines the value of an integer model parameter
709 ! from a parameter file. The arguments are the unit of the open file
710 ! which is to be read, the (case-sensitive) variable name, the variable
711 ! where the value is to be stored, and (optionally) a flag indicating
712 ! whether to fail if this parameter can not be found.
713  character(len=INPUT_STR_LENGTH) :: value_string(1)
714  logical :: found, defined
715 
716  call get_variable_line(cs, varname, found, defined, value_string)
717  if (found) then
718  value = trim(strip_quotes(value_string(1)))
719  elseif (present(fail_if_missing)) then ; if (fail_if_missing) then
720  call mom_error(fatal,'Unable to find variable '//trim(varname)// &
721  ' in any input files.')
722  endif ; endif
723 

◆ read_param_char_array()

subroutine mom_file_parser::read_param::read_param_char_array ( type(param_file_type), intent(in)  CS,
character(len=*), intent(in)  varname,
character(len=*), dimension(:), intent(inout)  value,
logical, intent(in), optional  fail_if_missing 
)
private

Definition at line 727 of file MOM_file_parser.F90.

727  type(param_file_type), intent(in) :: cs
728  character(len=*), intent(in) :: varname
729  character(len=*), intent(inout) :: value(:)
730  logical, optional, intent(in) :: fail_if_missing
731 ! This subroutine determines the value of an integer model parameter
732 ! from a parameter file. The arguments are the unit of the open file
733 ! which is to be read, the (case-sensitive) variable name, the variable
734 ! where the value is to be stored, and (optionally) a flag indicating
735 ! whether to fail if this parameter can not be found.
736  character(len=INPUT_STR_LENGTH) :: value_string(1), loc_string
737  logical :: found, defined
738  integer :: i, i_out
739 
740  call get_variable_line(cs, varname, found, defined, value_string)
741  if (found) then
742  loc_string = trim(value_string(1))
743  i = index(loc_string,",")
744  i_out = 1
745  do while(i>0)
746  value(i_out) = trim(strip_quotes(loc_string(:i-1)))
747  i_out = i_out+1
748  loc_string = trim(adjustl(loc_string(i+1:)))
749  i = index(loc_string,",")
750  enddo
751  if (len_trim(loc_string)>0) then
752  value(i_out) = trim(strip_quotes(adjustl(loc_string)))
753  i_out = i_out+1
754  endif
755  do i=i_out,SIZE(value) ; value(i) = " " ; enddo
756  elseif (present(fail_if_missing)) then ; if (fail_if_missing) then
757  call mom_error(fatal,'Unable to find variable '//trim(varname)// &
758  ' in any input files.')
759  endif ; endif
760 

◆ read_param_int()

subroutine mom_file_parser::read_param::read_param_int ( type(param_file_type), intent(in)  CS,
character(len=*), intent(in)  varname,
integer, intent(inout)  value,
logical, intent(in), optional  fail_if_missing 
)
private

Definition at line 574 of file MOM_file_parser.F90.

574  type(param_file_type), intent(in) :: cs
575  character(len=*), intent(in) :: varname
576  integer, intent(inout) :: value
577  logical, optional, intent(in) :: fail_if_missing
578 ! This subroutine determines the value of an integer model parameter
579 ! from a parameter file. The arguments are the unit of the open file
580 ! which is to be read, the (case-sensitive) variable name, the variable
581 ! where the value is to be stored, and (optionally) a flag indicating
582 ! whether to fail if this parameter can not be found.
583  character(len=INPUT_STR_LENGTH) :: value_string(1)
584  logical :: found, defined
585 
586  call get_variable_line(cs, varname, found, defined, value_string)
587  if (found .and. defined .and. (len_trim(value_string(1)) > 0)) then
588  read(value_string(1),*,err = 1001) value
589  else
590  if (present(fail_if_missing)) then ; if (fail_if_missing) then
591  if (.not.found) then
592  call mom_error(fatal,'read_param_int: Unable to find variable '//trim(varname)// &
593  ' in any input files.')
594  else
595  call mom_error(fatal,'read_param_int: Variable '//trim(varname)// &
596  ' found but not set in input files.')
597  endif
598  endif ; endif
599  endif
600  return
601  1001 call mom_error(fatal,'read_param_int: read error for integer variable '//trim(varname)// &
602  ' parsing "'//trim(value_string(1))//'"')

◆ read_param_int_array()

subroutine mom_file_parser::read_param::read_param_int_array ( type(param_file_type), intent(in)  CS,
character(len=*), intent(in)  varname,
integer, dimension(:), intent(inout)  value,
logical, intent(in), optional  fail_if_missing 
)
private

Definition at line 606 of file MOM_file_parser.F90.

606  type(param_file_type), intent(in) :: cs
607  character(len=*), intent(in) :: varname
608  integer, intent(inout) :: value(:)
609  logical, optional, intent(in) :: fail_if_missing
610 ! This subroutine determines the value of an integer model parameter
611 ! from a parameter file. The arguments are the unit of the open file
612 ! which is to be read, the (case-sensitive) variable name, the variable
613 ! where the value is to be stored, and (optionally) a flag indicating
614 ! whether to fail if this parameter can not be found.
615  character(len=INPUT_STR_LENGTH) :: value_string(1)
616  logical :: found, defined
617 
618  call get_variable_line(cs, varname, found, defined, value_string)
619  if (found .and. defined .and. (len_trim(value_string(1)) > 0)) then
620  read(value_string(1),*,end=991,err=1002) value
621  991 return
622  else
623  if (present(fail_if_missing)) then ; if (fail_if_missing) then
624  if (.not.found) then
625  call mom_error(fatal,'read_param_int_array: Unable to find variable '//trim(varname)// &
626  ' in any input files.')
627  else
628  call mom_error(fatal,'read_param_int_array: Variable '//trim(varname)// &
629  ' found but not set in input files.')
630  endif
631  endif ; endif
632  endif
633  return
634  1002 call mom_error(fatal,'read_param_int_array: read error for integer array '//trim(varname)// &
635  ' parsing "'//trim(value_string(1))//'"')

◆ read_param_logical()

subroutine mom_file_parser::read_param::read_param_logical ( type(param_file_type), intent(in)  CS,
character(len=*), intent(in)  varname,
logical, intent(inout)  value,
logical, intent(in), optional  fail_if_missing 
)
private

Definition at line 764 of file MOM_file_parser.F90.

764  type(param_file_type), intent(in) :: cs
765  character(len=*), intent(in) :: varname
766  logical, intent(inout) :: value
767  logical, optional, intent(in) :: fail_if_missing
768 ! This subroutine determines the value of an integer model parameter
769 ! from a parameter file. The arguments are the unit of the open file
770 ! which is to be read, the (case-sensitive) variable name, the variable
771 ! where the value is to be stored, and (optionally) a flag indicating
772 ! whether to fail if this parameter can not be found.
773  character(len=INPUT_STR_LENGTH) :: value_string(1)
774  logical :: found, defined
775 
776  call get_variable_line(cs, varname, found, defined, value_string, paramislogical=.true.)
777  if (found) then
778  value = defined
779  elseif (present(fail_if_missing)) then ; if (fail_if_missing) then
780  call mom_error(fatal,'Unable to find variable '//trim(varname)// &
781  ' in any input files.')
782  endif ; endif

◆ read_param_real()

subroutine mom_file_parser::read_param::read_param_real ( type(param_file_type), intent(in)  CS,
character(len=*), intent(in)  varname,
real, intent(inout)  value,
logical, intent(in), optional  fail_if_missing 
)
private

Definition at line 639 of file MOM_file_parser.F90.

639  type(param_file_type), intent(in) :: cs
640  character(len=*), intent(in) :: varname
641  real, intent(inout) :: value
642  logical, optional, intent(in) :: fail_if_missing
643 ! This subroutine determines the value of an integer model parameter
644 ! from a parameter file. The arguments are the unit of the open file
645 ! which is to be read, the (case-sensitive) variable name, the variable
646 ! where the value is to be stored, and (optionally) a flag indicating
647 ! whether to fail if this parameter can not be found.
648  character(len=INPUT_STR_LENGTH) :: value_string(1)
649  logical :: found, defined
650 
651  call get_variable_line(cs, varname, found, defined, value_string)
652  if (found .and. defined .and. (len_trim(value_string(1)) > 0)) then
653  read(value_string(1),*,err=1003) value
654  else
655  if (present(fail_if_missing)) then ; if (fail_if_missing) then
656  if (.not.found) then
657  call mom_error(fatal,'read_param_real: Unable to find variable '//trim(varname)// &
658  ' in any input files.')
659  else
660  call mom_error(fatal,'read_param_real: Variable '//trim(varname)// &
661  ' found but not set in input files.')
662  endif
663  endif ; endif
664  endif
665  return
666  1003 call mom_error(fatal,'read_param_real: read error for real variable '//trim(varname)// &
667  ' parsing "'//trim(value_string(1))//'"')

◆ read_param_real_array()

subroutine mom_file_parser::read_param::read_param_real_array ( type(param_file_type), intent(in)  CS,
character(len=*), intent(in)  varname,
real, dimension(:), intent(inout)  value,
logical, intent(in), optional  fail_if_missing 
)
private

Definition at line 671 of file MOM_file_parser.F90.

671  type(param_file_type), intent(in) :: cs
672  character(len=*), intent(in) :: varname
673  real, intent(inout) :: value(:)
674  logical, optional, intent(in) :: fail_if_missing
675 ! This subroutine determines the value of an integer model parameter
676 ! from a parameter file. The arguments are the unit of the open file
677 ! which is to be read, the (case-sensitive) variable name, the variable
678 ! where the value is to be stored, and (optionally) a flag indicating
679 ! whether to fail if this parameter can not be found.
680  character(len=INPUT_STR_LENGTH) :: value_string(1)
681  logical :: found, defined
682 
683  call get_variable_line(cs, varname, found, defined, value_string)
684  if (found .and. defined .and. (len_trim(value_string(1)) > 0)) then
685  read(value_string(1),*,end=991,err=1004) value
686  991 return
687  else
688  if (present(fail_if_missing)) then ; if (fail_if_missing) then
689  if (.not.found) then
690  call mom_error(fatal,'read_param_real_array: Unable to find variable '//trim(varname)// &
691  ' in any input files.')
692  else
693  call mom_error(fatal,'read_param_real_array: Variable '//trim(varname)// &
694  ' found but not set in input files.')
695  endif
696  endif ; endif
697  endif
698  return
699  1004 call mom_error(fatal,'read_param_real_array: read error for real array '//trim(varname)// &
700  ' parsing "'//trim(value_string(1))//'"')

◆ read_param_time()

subroutine mom_file_parser::read_param::read_param_time ( type(param_file_type), intent(in)  CS,
character(len=*), intent(in)  varname,
type(time_type), intent(inout)  value,
real, intent(in), optional  timeunit,
logical, intent(in), optional  fail_if_missing,
logical, intent(out), optional  date_format 
)
private

Definition at line 787 of file MOM_file_parser.F90.

787  type(param_file_type), intent(in) :: cs
788  character(len=*), intent(in) :: varname
789  type(time_type), intent(inout) :: value
790  real, optional, intent(in) :: timeunit
791  logical, optional, intent(in) :: fail_if_missing
792  logical, optional, intent(out) :: date_format
793 ! This subroutine determines the value of an time-type model parameter
794 ! from a parameter file. The arguments are the unit of the open file
795 ! which is to be read, the (case-sensitive) variable name, the variable
796 ! where the value is to be stored, and (optionally) a flag indicating
797 ! whether to fail if this parameter can not be found. The unique argument
798 ! to read time is the number of seconds to use as the unit of time being read.
799  character(len=INPUT_STR_LENGTH) :: value_string(1)
800  character(len=240) :: err_msg
801  logical :: found, defined
802  real :: real_time, time_unit
803  integer :: days, secs, vals(7)
804 
805  if (present(date_format)) date_format = .false.
806 
807  call get_variable_line(cs, varname, found, defined, value_string)
808  if (found .and. defined .and. (len_trim(value_string(1)) > 0)) then
809  ! Determine whether value string should be parsed for a real number
810  ! or a date, in either a string format or a comma-delimited list of values.
811  if ((index(value_string(1),'-') > 0) .and. &
812  (index(value_string(1),'-',back=.true.) > index(value_string(1),'-'))) then
813  ! There are two dashes, so this must be a date format.
814  value = set_date(value_string(1), err_msg=err_msg)
815  if (len_trim(err_msg) > 0) call mom_error(fatal,'read_param_time: '//&
816  trim(err_msg)//' in integer list read error for time-type variable '//&
817  trim(varname)// ' parsing "'//trim(value_string(1))//'"')
818  if (present(date_format)) date_format = .true.
819  elseif (index(value_string(1),',') > 0) then
820  ! Initialize vals with an invalid date.
821  vals(:) = (/ -999, -999, -999, 0, 0, 0, 0 /)
822  read(value_string(1),*,end=995,err=1005) vals
823  995 continue
824  if ((vals(1) < 0) .or. (vals(2) < 0) .or. (vals(3) < 0)) &
825  call mom_error(fatal,'read_param_time: integer list read error for time-type variable '//&
826  trim(varname)// ' parsing "'//trim(value_string(1))//'"')
827  value = set_date(vals(1), vals(2), vals(3), vals(4), vals(5), vals(6), &
828  vals(7), err_msg=err_msg)
829  if (len_trim(err_msg) > 0) call mom_error(fatal,'read_param_time: '//&
830  trim(err_msg)//' in integer list read error for time-type variable '//&
831  trim(varname)// ' parsing "'//trim(value_string(1))//'"')
832  if (present(date_format)) date_format = .true.
833  else
834  time_unit = 1.0 ; if (present(timeunit)) time_unit = timeunit
835  read( value_string(1), *) real_time
836  days = int(real_time*(time_unit/86400.0))
837  secs = int(floor((real_time*(time_unit/86400.0)-days)*86400.0 + 0.5))
838  value = set_time(secs, days)
839  endif
840  else
841  if (present(fail_if_missing)) then ; if (fail_if_missing) then
842  if (.not.found) then
843  call mom_error(fatal,'Unable to find variable '//trim(varname)// &
844  ' in any input files.')
845  else
846  call mom_error(fatal,'Variable '//trim(varname)// &
847  ' found but not set in input files.')
848  endif
849  endif ; endif
850  endif
851  return
852  1005 call mom_error(fatal,'read_param_time: read error for time-type variable '//&
853  trim(varname)// ' parsing "'//trim(value_string(1))//'"')

The documentation for this interface was generated from the following file: