Skip to content

Commit

Permalink
file closer str python
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholaswogan committed Jun 11, 2024
1 parent b9c3d4e commit a25ed14
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION "3.14")
cmake_policy(SET CMP0148 OLD) # To suppress a warning emerging from scikit-build

project(Clima LANGUAGES Fortran C VERSION "0.4.5")
project(Clima LANGUAGES Fortran C VERSION "0.4.6")

set(CMAKE_Fortran_MODULE_DIRECTORY "${CMAKE_BINARY_DIR}/modules")

Expand Down
6 changes: 3 additions & 3 deletions clima/cython/AdiabatClimate.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ cdef class AdiabatClimate:
raise ClimaException('The "__init__" method of AdiabatClimate has not been called.')
PyObject_GenericSetAttr(self, name, value)

def __init__(self, species_file = None, settings_file = None,
flux_file = None, data_dir = None, cbool double_radiative_grid = True):
def __init__(self, str species_file, str settings_file,
str flux_file, data_dir = None, cbool double_radiative_grid = True):
"""Initializes `AdiabatClimate`
Parameters
Expand Down Expand Up @@ -379,7 +379,7 @@ cdef class AdiabatClimate:
if len(err.strip()) > 0:
raise ClimaException(err.decode("utf-8").strip())

def out2atmosphere_txt(self, filename, ndarray[double, ndim=1] eddy, cbool overwrite = False, cbool clip = True):
def out2atmosphere_txt(self, str filename, ndarray[double, ndim=1] eddy, cbool overwrite = False, cbool clip = True):
"""Saves state of the atmosphere to a file.
Parameters
Expand Down
6 changes: 4 additions & 2 deletions src/adiabat/clima_adiabat.f90
Original file line number Diff line number Diff line change
Expand Up @@ -950,11 +950,13 @@ subroutine AdiabatClimate_to_regular_grid(self, err)
end subroutine

subroutine AdiabatClimate_out2atmosphere_txt(self, filename, eddy, overwrite, clip, err)
use futils, only: FileCloser
class(AdiabatClimate), target, intent(inout) :: self
character(len=*), intent(in) :: filename
real(dp), intent(in) :: eddy(:)
logical, intent(in) :: overwrite, clip
character(:), allocatable, intent(out) :: err
type(FileCloser) :: file

character(len=100) :: tmp
integer :: io, i, j
Expand All @@ -969,12 +971,14 @@ subroutine AdiabatClimate_out2atmosphere_txt(self, filename, eddy, overwrite, cl

if (overwrite) then
open(2, file=filename, form='formatted', status='replace', iostat=io)
file%unit = 2
if (io /= 0) then
err = "Unable to overwrite file "//trim(filename)
return
endif
else
open(2, file=filename, form='formatted', status='new', iostat=io)
file%unit = 2
if (io /= 0) then
err = "Unable to create file "//trim(filename)//" because it already exists"
return
Expand Down Expand Up @@ -1012,8 +1016,6 @@ subroutine AdiabatClimate_out2atmosphere_txt(self, filename, eddy, overwrite, cl
enddo
enddo

close(2)

end subroutine

!> For considering a tidally locked planet. This function computes key parameters for
Expand Down
4 changes: 2 additions & 2 deletions src/dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ CPMAddPackage(
# futils
CPMAddPackage(
NAME futils
VERSION 0.1.9
VERSION 0.1.11
GITHUB_REPOSITORY "Nicholaswogan/futils"
GIT_TAG "v0.1.9"
GIT_TAG "v0.1.11"
EXCLUDE_FROM_ALL ON
)

Expand Down

0 comments on commit a25ed14

Please sign in to comment.