[Dart-dev] DART/branches Revision: 12065
dart at ucar.edu
dart at ucar.edu
Wed Nov 8 09:57:24 MST 2017
thoar at ucar.edu
2017-11-08 09:57:22 -0700 (Wed, 08 Nov 2017)
145
Check for files previously closed before trying to close again.
Only an issue because existing logic was for a separate file for each variable.
Modified: DART/branches/coamps/models/coamps_nest/coamps_nest_mod.f90
===================================================================
--- DART/branches/coamps/models/coamps_nest/coamps_nest_mod.f90 2017-11-08 16:32:44 UTC (rev 12064)
+++ DART/branches/coamps/models/coamps_nest/coamps_nest_mod.f90 2017-11-08 16:57:22 UTC (rev 12065)
@@ -26,7 +26,7 @@
use types_mod, only : r4, r8
- use utilities_mod, only: E_ERR, error_handler, get_unit
+ use utilities_mod, only: E_MSG, E_ERR, error_handler, get_unit
use netcdf_utilities_mod, only : nc_check
@@ -1189,7 +1189,7 @@
integer :: io
integer :: alloc_status
integer :: dealloc_status
-character(len=512) :: string1
+character(len=512) :: string0, string1, string2, string3
! Permanent storage
nullify(nest%terrain)
@@ -1239,12 +1239,13 @@
io = nf90_close(terrht_unit)
call nc_check(io, routine, 'closing "'//trim(filename)//'"')
-if ( .true. ) then
- write(*,*)routine,' nest id ', nest%id
- write(*,*)routine,' range of terrain is ',minval(nest%terrain), maxval(nest%terrain)
- write(*,*)routine,' range of latitude is ',minval(nest%lat), maxval(nest%lat)
- write(*,*)routine,' range of longitude is ',minval(nest%lon), maxval(nest%lon)
+! String1 has to be different to print nicely, given error_handler() nuances.
+write(string1,100)'... nest',nest%id,' terrain range',minval(nest%terrain), maxval(nest%terrain)
+write(string2,100)'nest',nest%id,' latitude range',minval(nest%lat), maxval(nest%lat)
+write(string3,100)'nest',nest%id,'longitude range',minval(nest%lon), maxval(nest%lon)
+call error_handler(E_MSG,routine,string1,text2=string2,text3=string3)
+if ( .false. ) then
write(*,*)routine,' lon/lat ( 1, 1) is ',nest%lon( 1, 1), nest%lat( 1, 1)
write(*,*)routine,' lon/lat (200, 1) is ',nest%lon(200, 1), nest%lat(200, 1)
write(*,*)routine,' lon/lat ( 1, 2) is ',nest%lon( 1, 2), nest%lat( 1, 2)
@@ -1251,9 +1252,10 @@
write(*,*)routine,' lon/lat (100, 50) is ',nest%lon(100,50), nest%lat(100,50)
write(*,*)routine,' lon/lat ( nx, ny) is ',nest%lon(nest%pts_x,nest%pts_y), &
nest%lat(nest%pts_x,nest%pts_y)
-
endif
+100 format(A,1x,I2,1x,A,2(1x,f12.4))
+
end subroutine read_geographic_data
Modified: DART/branches/coamps/models/coamps_nest/coamps_translate_mod.f90
===================================================================
--- DART/branches/coamps/models/coamps_nest/coamps_translate_mod.f90 2017-11-08 16:32:44 UTC (rev 12064)
+++ DART/branches/coamps/models/coamps_nest/coamps_translate_mod.f90 2017-11-08 16:57:22 UTC (rev 12065)
@@ -338,17 +338,23 @@
! PARAMETERS
! [none]
subroutine finalize_translator()
- integer :: cur_file
character(len=*), parameter :: routine = 'finalize_translator'
- integer :: dealloc_status
+ integer :: cur_file, iunit
+ integer :: io_status, dealloc_status
+ logical :: lopen
deallocate(dart_state, stat=dealloc_status)
call check_dealloc_status(dealloc_status, routine, source, &
revision, revdate, 'dart_state' )
+ ! Since one file has mutiple variables, you can only close it once.
do cur_file = 1, total_coamps_files
- close(coamps_file_units(cur_file))
+ iunit = coamps_file_units(cur_file)
+ inquire (unit=iunit, opened=lopen, iostat=io_status)
+ call check_io_status(io_status, routine, source, revision, &
+ revdate, 'Closing "'//coamps_file_names(cur_file)//'"')
+ if (lopen) close(iunit)
end do
close(dart_unit)
More information about the Dart-dev
mailing list