|
4 | 4 |
|
5 | 5 | module scm_input |
6 | 6 |
|
| 7 | +use iso_fortran_env, only: error_unit |
7 | 8 | use scm_kinds, only : sp, dp, qp |
8 | 9 | use netcdf |
9 | 10 | use scm_type_defs, only: character_length |
@@ -128,15 +129,15 @@ subroutine get_config_nml(scm_state) |
128 | 129 |
|
129 | 130 | open(unit=10, file=experiment_namelist, status='old', action='read', iostat=ioerror) |
130 | 131 | if(ioerror /= 0) then |
131 | | - write(*,'(a,i0)') 'There was an error opening the file ' // experiment_namelist // & |
| 132 | + write(error_unit,'(a,i0)') 'There was an error opening the file ' // experiment_namelist // & |
132 | 133 | '; error code = ', ioerror |
133 | 134 | error stop "error opening namelist" |
134 | 135 | else |
135 | 136 | read(10, NML=case_config, iostat=ioerror) |
136 | 137 | end if |
137 | 138 |
|
138 | 139 | if(ioerror /= 0) then |
139 | | - write(*,'(a,i0)') 'There was an error reading the namelist case_config in the file '& |
| 140 | + write(error_unit,'(a,i0)') 'There was an error reading the namelist case_config in the file '& |
140 | 141 | // experiment_namelist // '; error code = ',ioerror |
141 | 142 | error stop "error opening namelist" |
142 | 143 | end if |
@@ -502,7 +503,7 @@ subroutine get_case_init(scm_state, scm_input) |
502 | 503 | call NetCDF_read_var(grp_ncid, "thetail", .False., input_thetail) |
503 | 504 | call NetCDF_read_var(grp_ncid, "temp", .False., input_temp) |
504 | 505 | if (maxval(input_thetail) < 0 .and. maxval(input_temp) < 0) then |
505 | | - write(*,*) "One of thetail or temp variables must be present in ",trim(adjustl(scm_state%case_name))//'.nc',". Stopping..." |
| 506 | + write(error_unit,*) "One of thetail or temp variables must be present in ",trim(adjustl(scm_state%case_name))//'.nc',". Stopping..." |
506 | 507 | error stop "One of thetail or temp variables" |
507 | 508 | end if |
508 | 509 | call NetCDF_read_var(grp_ncid, "qt", .True., input_qt ) |
@@ -1215,8 +1216,8 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) |
1215 | 1216 | else if (adjustl(trim(tmpUnits)) == 'm') then |
1216 | 1217 | lev_in_altitude = .true. |
1217 | 1218 | else |
1218 | | - write(0,'(a,i0,a)') "The variable 'lev' in the case data file had units different than 'm', 'pa', or 'Pa', but it is expected to be altitude in m or pressure in Pa. Stopping..." |
1219 | | - STOP |
| 1219 | + write(error_unit,'(a,i0,a)') "The variable 'lev' in the case data file had units different than 'm', 'pa', or 'Pa', but it is expected to be altitude in m or pressure in Pa. Stopping..." |
| 1220 | + error stop |
1220 | 1221 | end if |
1221 | 1222 |
|
1222 | 1223 | !### TO BE USED IF DEPHY-SCM can be extended to include model ICs ### |
@@ -2035,7 +2036,7 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) |
2035 | 2036 | end if !ql test |
2036 | 2037 | else |
2037 | 2038 | !no qv or qt |
2038 | | - write(*,*) 'When reading '//trim(adjustl(scm_state%case_name))//'.nc, all of the supported moisture variables (qv, qt, rv, rt) were missing. Stopping...' |
| 2039 | + write(error_unit,*) 'When reading '//trim(adjustl(scm_state%case_name))//'.nc, all of the supported moisture variables (qv, qt, rv, rt) were missing. Stopping...' |
2039 | 2040 | error stop "Aall of the supported moisture variables (qv, qt, rv, rt) were missing" |
2040 | 2041 | end if |
2041 | 2042 |
|
@@ -2065,7 +2066,7 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) |
2065 | 2066 | !since thetail is present, choose to use it, and set the alternative temperature to missing, even if it is also present in the file |
2066 | 2067 | scm_input%input_temp = missing_value |
2067 | 2068 | else |
2068 | | - write(*,*) 'When reading '//trim(adjustl(scm_state%case_name))//'.nc, all of the supported temperature variables (temp, theta, thetal) were missing. Stopping...' |
| 2069 | + write(error_unit,*) 'When reading '//trim(adjustl(scm_state%case_name))//'.nc, all of the supported temperature variables (temp, theta, thetal) were missing. Stopping...' |
2069 | 2070 | error stop "All of the supported temperature variables (temp, theta, thetal) were missing" |
2070 | 2071 | end if |
2071 | 2072 |
|
@@ -2134,7 +2135,7 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) |
2134 | 2135 |
|
2135 | 2136 | if (input_surfaceForcingTemp == 'ts') then |
2136 | 2137 | if (maxval(input_force_ts) < 0) then |
2137 | | - write(*,*) 'The global attribute surfaceForcing in '//trim(adjustl(scm_state%case_name))//'.nc indicates that the variable ts should be present, but it is missing. Stopping ...' |
| 2138 | + write(error_unit,*) 'The global attribute surfaceForcing in '//trim(adjustl(scm_state%case_name))//'.nc indicates that the variable ts should be present, but it is missing. Stopping ...' |
2138 | 2139 | error stop "The global attribute surfaceForcing indicates that the variable ts should be present, but it is missing" |
2139 | 2140 | else |
2140 | 2141 | !overwrite sfc_flux_spec |
@@ -2166,7 +2167,7 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) |
2166 | 2167 |
|
2167 | 2168 | !kinematic surface fluxes are specified (but may need to be converted) |
2168 | 2169 | if (maxval(input_force_wpthetap(:)) < missing_value_eps) then |
2169 | | - write(*,*) 'The global attribute surfaceForcing in '//trim(adjustl(scm_state%case_name))//'.nc indicates that the variable wpthetap should be present, but it is missing. Stopping ...' |
| 2170 | + write(error_unit,*) 'The global attribute surfaceForcing in '//trim(adjustl(scm_state%case_name))//'.nc indicates that the variable wpthetap should be present, but it is missing. Stopping ...' |
2170 | 2171 | error stop "The global attribute surfaceForcing indicates that the variable wpthetap should be present, but it is missing." |
2171 | 2172 | else |
2172 | 2173 | !convert from theta to T |
@@ -2196,7 +2197,7 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) |
2196 | 2197 | end if |
2197 | 2198 |
|
2198 | 2199 | if (maxval(input_force_wpqvp(:)) < missing_value_eps .and. maxval(input_force_wpqtp(:)) < missing_value_eps) then |
2199 | | - write(*,*) 'The global attribute surfaceForcing in '//trim(adjustl(scm_state%case_name))//'.nc indicates that the variable wpqvp, wpqtp, wprvp, or wprtp should be present, but all are missing. Stopping ...' |
| 2200 | + write(error_unit,*) 'The global attribute surfaceForcing in '//trim(adjustl(scm_state%case_name))//'.nc indicates that the variable wpqvp, wpqtp, wprvp, or wprtp should be present, but all are missing. Stopping ...' |
2200 | 2201 | error stop "The global attribute surfaceForcing indicates that the variable wpqvp, wpqtp, wprvp, or wprtp should be present, but all are missing." |
2201 | 2202 | else |
2202 | 2203 | if (maxval(input_force_wpqvp(:)) > missing_value_eps) then !use wpqvp if available |
@@ -2230,14 +2231,14 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) |
2230 | 2231 |
|
2231 | 2232 |
|
2232 | 2233 | if (maxval(input_force_sfc_sens_flx(:)) < missing_value_eps) then |
2233 | | - write(*,*) 'The global attribute surfaceForcing in '//trim(adjustl(scm_state%case_name))//'.nc indicates that the variable sfc_sens_flx should be present, but it is missing. Stopping ...' |
| 2234 | + write(error_unit,*) 'The global attribute surfaceForcing in '//trim(adjustl(scm_state%case_name))//'.nc indicates that the variable sfc_sens_flx should be present, but it is missing. Stopping ...' |
2234 | 2235 | error stop "The global attribute surfaceForcing in indicates that the variable sfc_sens_flx should be present, but it is missing." |
2235 | 2236 | else |
2236 | 2237 | scm_input%input_sh_flux_sfc = input_force_sfc_sens_flx(:) |
2237 | 2238 | end if |
2238 | 2239 |
|
2239 | 2240 | if (maxval(input_force_sfc_lat_flx(:)) < missing_value_eps) then |
2240 | | - write(*,*) 'The global attribute surfaceForcing in '//trim(adjustl(scm_state%case_name))//'.nc indicates that the variable sfc_lat_flx should be present, but it is missing. Stopping ...' |
| 2241 | + write(error_unit,*) 'The global attribute surfaceForcing in '//trim(adjustl(scm_state%case_name))//'.nc indicates that the variable sfc_lat_flx should be present, but it is missing. Stopping ...' |
2241 | 2242 | error stop "The global attribute surfaceForcing indicates that the variable sfc_lat_flx should be present, but it is missing." |
2242 | 2243 | else |
2243 | 2244 | scm_input%input_lh_flux_sfc = input_force_sfc_lat_flx(:) |
@@ -2352,7 +2353,7 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) |
2352 | 2353 | else if (input_surfaceForcingWind == 'ustar') then |
2353 | 2354 | !not supported |
2354 | 2355 | scm_state%surface_momentum_control = 1 |
2355 | | - write(*,*) 'The global attribute surfaceForcingWind in '//trim(adjustl(scm_state%case_name))//'.nc indicates that surface wind is controlled by a specified time-series of ustar. This is currently not supported. Stopping ...' |
| 2356 | + write(error_unit,*) 'The global attribute surfaceForcingWind in '//trim(adjustl(scm_state%case_name))//'.nc indicates that surface wind is controlled by a specified time-series of ustar. This is currently not supported. Stopping ...' |
2356 | 2357 | error stop "The global attribute surfaceForcingWind indicates that surface wind is controlled by a specified time-series of ustar. This is currently not supported." |
2357 | 2358 | end if |
2358 | 2359 |
|
@@ -2454,7 +2455,7 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) |
2454 | 2455 | if (char_rad_temp == 'adv' .or. char_rad_theta == 'adv' .or. char_rad_thetal == 'adv') then |
2455 | 2456 | scm_state%force_rad_T = 4 |
2456 | 2457 | if (scm_state%force_adv_T == 0) then |
2457 | | - write(*,*) 'The global attribute rad_temp, rad_theta, or rad_thetal in '//trim(adjustl(scm_state%case_name))//'.nc indicates that radiative forcing is included in the advection term, but there is no advection term. Stopping ...' |
| 2458 | + write(error_unit,*) 'The global attribute rad_temp, rad_theta, or rad_thetal in '//trim(adjustl(scm_state%case_name))//'.nc indicates that radiative forcing is included in the advection term, but there is no advection term. Stopping ...' |
2458 | 2459 | error stop "The global attribute rad_temp, rad_theta, or rad_thetal indicates that radiative forcing is included in the advection term, but there is no advection term." |
2459 | 2460 | end if |
2460 | 2461 | else if (rad_temp > 0) then |
@@ -2750,7 +2751,7 @@ subroutine get_reference_profile(scm_state, scm_reference) |
2750 | 2751 | case (1) |
2751 | 2752 | open(unit=1, file='McCProfiles.dat', status='old', action='read', iostat=ioerror) |
2752 | 2753 | if(ioerror /= 0) then |
2753 | | - write(*,*) 'There was an error opening the file McCprofiles.dat in the processed_case_input directory. & |
| 2754 | + write(error_unit,*) 'There was an error opening the file McCprofiles.dat in the processed_case_input directory. & |
2754 | 2755 | &Error code = ',ioerror |
2755 | 2756 | error stop "There was an error opening the file McCprofiles.dat in the processed_case_input directory." |
2756 | 2757 | endif |
@@ -2860,7 +2861,7 @@ subroutine get_tracers(tracer_names, tracer_types) |
2860 | 2861 | tracer_types(i) = 0 ! temporary until SCM is configured to work with GOCART |
2861 | 2862 | end do |
2862 | 2863 | else |
2863 | | - write(*,'(a,i0)') 'There was an error opening the file ' // FILE_NAME // & |
| 2864 | + write(error_unit,'(a,i0)') 'There was an error opening the file ' // FILE_NAME // & |
2864 | 2865 | '; error code = ', rc |
2865 | 2866 | error stop "Error opening tracers file" |
2866 | 2867 | end if |
|
0 commit comments