diff --git a/CMakeLists.txt b/CMakeLists.txt index 167e0af..fc7411c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION "3.14") -project(Photochem LANGUAGES Fortran C VERSION "0.3.7") +project(Photochem LANGUAGES Fortran C VERSION "0.3.8") include(FortranCInterface) FortranCInterface_VERIFY() diff --git a/src/dependencies/CMakeLists.txt b/src/dependencies/CMakeLists.txt index 5176def..842e80f 100644 --- a/src/dependencies/CMakeLists.txt +++ b/src/dependencies/CMakeLists.txt @@ -19,9 +19,9 @@ CPMAddPackage( CPMAddPackage( NAME fortran-yaml-c - VERSION 0.1.2 + VERSION 0.2.1 GITHUB_REPOSITORY "Nicholaswogan/fortran-yaml-c" - GIT_TAG "v0.1.2" + GIT_TAG "v0.2.1" EXCLUDE_FROM_ALL ON ) @@ -49,10 +49,10 @@ CPMAddPackage( CPMAddPackage( NAME clima - VERSION 0.2.0 + VERSION 0.2.3 OPTIONS "BUILD_WITH_OPENMP ${BUILD_WITH_OPENMP}" GITHUB_REPOSITORY "Nicholaswogan/clima" - GIT_TAG "v0.2.0" + GIT_TAG "v0.2.3" EXCLUDE_FROM_ALL ON ) \ No newline at end of file diff --git a/src/input/photochem_input.f90 b/src/input/photochem_input.f90 index c0fbf9d..e223212 100644 --- a/src/input/photochem_input.f90 +++ b/src/input/photochem_input.f90 @@ -1,6 +1,6 @@ module photochem_input - use yaml_types, only : type_node, type_dictionary, type_list, type_error, & + use fortran_yaml_c_types, only : type_node, type_dictionary, type_list, type_error, & type_list_item, type_scalar, type_key_value_pair use photochem_types, only : PhotochemData, PhotochemVars, PhotoSettings use photochem_const, only: dp, str_len, s_str_len diff --git a/src/input/photochem_input_read.f90 b/src/input/photochem_input_read.f90 index 41c74ec..e83c124 100644 --- a/src/input/photochem_input_read.f90 +++ b/src/input/photochem_input_read.f90 @@ -54,29 +54,24 @@ module subroutine read_all_files(mechanism_file, s, flux_file, atmosphere_txt, b end subroutine subroutine get_photomech(infile, dat, var, err) - use fortran_yaml_c, only : parse, error_length + use fortran_yaml_c, only : YamlFile character(len=*), intent(in) :: infile type(PhotochemData), intent(inout) :: dat type(PhotochemVars), intent(in) :: var character(:), allocatable, intent(out) :: err - character(error_length) :: error - class (type_node), pointer :: root - + type(YamlFile) :: file + ! parse yaml file - root => parse(infile,error=error) - if (error /= '') then - err = trim(error) - return - end if - select type (root) + call file%parse(infile, err) + if (allocated(err)) return + select type (root => file%root) class is (type_dictionary) call get_rxmechanism(root, infile, dat, var, err) class default err = "yaml file must have dictionaries at root level" end select - call root%finalize() - deallocate(root) + call file%finalize() if (allocated(err)) return end subroutine @@ -1000,33 +995,28 @@ subroutine get_henry_parse(root, dat, var, henry_names, henry_data, err) subroutine get_henry(dat, var, s, err) use photochem_types, only: PhotoSettings - use fortran_yaml_c, only : parse, error_length + use fortran_yaml_c, only : YamlFile type(PhotochemData), intent(inout) :: dat type(PhotochemVars), intent(in) :: var type(PhotoSettings), intent(in) :: s character(:), allocatable :: err - character(error_length) :: error - class (type_node), pointer :: root + type(YamlFile) :: file integer :: j, ind, ind1, i character(len=s_str_len), allocatable :: henry_names(:) real(dp), allocatable :: henry_data(:,:) ! parse yaml file - root => parse(trim(var%data_dir)//"/henry/henry.yaml",error=error) - if (error /= '') then - err = trim(error) - return - end if - select type (root) + call file%parse(trim(var%data_dir)//"/henry/henry.yaml", err) + if (allocated(err)) return + select type (root => file%root) class is (type_list) call get_henry_parse(root, dat, var, henry_names, henry_data, err) class default err = "yaml file must have dictionaries at root level" end select - call root%finalize() - deallocate(root) + call file%finalize() if (allocated(err)) return allocate(dat%henry_data(2,dat%nsp)) @@ -2365,7 +2355,7 @@ subroutine get_photolysis_xs(dat, var, err) subroutine get_rayleigh(dat, var, err) - use fortran_yaml_c, only : parse, error_length + use fortran_yaml_c, only : YamlFile type(PhotochemData), intent(inout) :: dat type(PhotochemVars), intent(in) :: var character(:), allocatable, intent(out) :: err @@ -2373,25 +2363,20 @@ subroutine get_rayleigh(dat, var, err) real(dp), allocatable :: A(:), B(:), Delta(:) character(len=str_len) :: rayleigh_file - character(error_length) :: error - class (type_node), pointer :: root + type(YamlFile) :: file integer :: i, j rayleigh_file = trim(var%data_dir)//"/rayleigh/rayleigh.yaml" ! parse yaml file - root => parse(rayleigh_file,error=error) - if (error /= '') then - err = trim(error) - return - end if - select type (root) + call file%parse(rayleigh_file, err) + if (allocated(err)) return + select type (root => file%root) class is (type_dictionary) call rayleigh_params(root,dat,trim(rayleigh_file),err, & dat%raynums, A, B, Delta) end select - call root%finalize() - deallocate(root) + call file%finalize() if (allocated(err)) return ! compute cross sections diff --git a/src/photochem_types_create.f90 b/src/photochem_types_create.f90 index c82b4e6..0f25359 100644 --- a/src/photochem_types_create.f90 +++ b/src/photochem_types_create.f90 @@ -1,35 +1,30 @@ submodule (photochem_types) photochem_types_create - use yaml_types, only : type_node, type_dictionary, type_list, type_error, & - type_list_item, type_scalar, type_key_value_pair + use fortran_yaml_c_types, only : type_node, type_dictionary, type_list, type_error, & + type_list_item, type_scalar, type_key_value_pair implicit none contains module function create_PhotoSettings(filename, err) result(s) - use fortran_yaml_c, only : parse, error_length + use fortran_yaml_c, only : YamlFile use photochem_types, only: PhotoSettings character(*), intent(in) :: filename character(:), allocatable, intent(out) :: err type(PhotoSettings) :: s - character(error_length) :: error - class (type_node), pointer :: root + type(YamlFile) :: file ! parse yaml file - root => parse(filename,error=error) - if (error /= '') then - err = trim(error) - return - end if - select type (root) + call file%parse(filename, err) + if (allocated(err)) return + select type (root => file%root) class is (type_dictionary) s = unpack_PhotoSettings(root, filename, err) class default err = "yaml file must have dictionaries at root level" end select - call root%finalize() - deallocate(root) + call file%finalize() if (allocated(err)) return end function