| 1 | MODULE read_data_PCM_mod |
|---|
| 2 | |
|---|
| 3 | use netcdf, only: nf90_open, NF90_NOWRITE, nf90_noerr, nf90_strerror, & |
|---|
| 4 | nf90_get_var, nf90_inq_varid, nf90_inq_dimid, & |
|---|
| 5 | nf90_inquire_dimension, nf90_close |
|---|
| 6 | |
|---|
| 7 | implicit none |
|---|
| 8 | |
|---|
| 9 | character(13), parameter :: modname = 'read_data_PCM' |
|---|
| 10 | character(256) :: msg ! for reading |
|---|
| 11 | integer :: fID, vID ! for reading |
|---|
| 12 | |
|---|
| 13 | !======================================================================= |
|---|
| 14 | contains |
|---|
| 15 | !======================================================================= |
|---|
| 16 | |
|---|
| 17 | SUBROUTINE read_data_PCM(filename,timelen,iim_input,jjm_input,ngrid,nslope,vmr_co2_gcm_phys,ps_timeseries, & |
|---|
| 18 | min_co2_ice,min_h2o_ice,tsurf_ave,tsoil_ave,tsurf_gcm,tsoil_gcm,q_co2,q_h2o,co2_ice_slope, & |
|---|
| 19 | watersurf_density_ave,watersoil_density) |
|---|
| 20 | use comsoil_h, only: nsoilmx |
|---|
| 21 | use comsoil_h_PEM, only: soil_pem |
|---|
| 22 | use constants_marspem_mod, only: m_co2, m_noco2 |
|---|
| 23 | |
|---|
| 24 | implicit none |
|---|
| 25 | |
|---|
| 26 | !======================================================================= |
|---|
| 27 | ! |
|---|
| 28 | ! Purpose: Read initial confitions file from the PCM |
|---|
| 29 | ! |
|---|
| 30 | ! Authors: RV & LL |
|---|
| 31 | !======================================================================= |
|---|
| 32 | |
|---|
| 33 | include "dimensions.h" |
|---|
| 34 | |
|---|
| 35 | !======================================================================= |
|---|
| 36 | ! Arguments: |
|---|
| 37 | |
|---|
| 38 | character(len = *), intent(in) :: filename ! File name |
|---|
| 39 | integer, intent(in) :: timelen ! number of times stored in the file |
|---|
| 40 | integer :: iim_input, jjm_input, ngrid, nslope ! number of points in the lat x lon dynamical grid, number of subgrid slopes |
|---|
| 41 | ! Ouputs |
|---|
| 42 | real, dimension(ngrid,nslope), intent(out) :: min_co2_ice ! Minimum of co2 ice per slope of the year [kg/m^2] |
|---|
| 43 | real, dimension(ngrid,nslope), intent(out) :: min_h2o_ice ! Minimum of h2o ice per slope of the year [kg/m^2] |
|---|
| 44 | real, dimension(ngrid,timelen), intent(out) :: vmr_co2_gcm_phys ! Physics x Times co2 volume mixing ratio retrieve from the PCM [m^3/m^3] |
|---|
| 45 | real, dimension(ngrid,timelen), intent(out) :: ps_timeseries ! Surface Pressure [Pa] |
|---|
| 46 | real, dimension(ngrid,timelen), intent(out) :: q_co2 ! CO2 mass mixing ratio in the first layer [kg/m^3] |
|---|
| 47 | real, dimension(ngrid,timelen), intent(out) :: q_h2o ! H2O mass mixing ratio in the first layer [kg/m^3] |
|---|
| 48 | real, dimension(ngrid,nslope,timelen), intent(out) :: co2_ice_slope ! co2 ice amount per slope of the year [kg/m^2] |
|---|
| 49 | !SOIL |
|---|
| 50 | real, dimension(ngrid,nslope), intent(out) :: tsurf_ave ! Average surface temperature of the concatenated file [K] |
|---|
| 51 | real, dimension(ngrid,nsoilmx,nslope), intent(out) :: tsoil_ave ! Average soil temperature of the concatenated file [K] |
|---|
| 52 | real, dimension(ngrid,nslope,timelen), intent(out) :: tsurf_gcm ! Surface temperature of the concatenated file, time series [K] |
|---|
| 53 | real, dimension(ngrid,nsoilmx,nslope,timelen), intent(out) :: tsoil_gcm ! Soil temperature of the concatenated file, time series [K] |
|---|
| 54 | real, dimension(ngrid,nslope), intent(out) :: watersurf_density_ave ! Water density at the surface [kg/m^3] |
|---|
| 55 | real, dimension(ngrid,nsoilmx,nslope,timelen), intent(out) :: watersoil_density ! Water density in the soil layer, time series [kg/m^3] |
|---|
| 56 | !======================================================================= |
|---|
| 57 | ! Local Variables |
|---|
| 58 | character(12) :: start_file_type = "earth" ! default start file type |
|---|
| 59 | real, dimension(:), allocatable :: time ! times stored in start |
|---|
| 60 | integer :: indextime ! index of selected time |
|---|
| 61 | integer :: edges(4), corner(4) |
|---|
| 62 | integer :: i, j, l, t ! loop variables |
|---|
| 63 | real :: A, B, mmean ! Molar Mass of co2 and no co2, A;B intermediate variables to compute the mean molar mass of the layer |
|---|
| 64 | integer :: islope ! loop for variables |
|---|
| 65 | character(2) :: num ! for reading sloped variables |
|---|
| 66 | real, dimension(iim_input + 1,jjm_input + 1,nslope,timelen) :: h2o_ice_s_dyn ! h2o ice per slope of the concatenated file [kg/m^2] |
|---|
| 67 | real, dimension(iim_input + 1,jjm_input + 1,nslope,timelen) :: watercap |
|---|
| 68 | real, dimension(iim_input + 1,jjm_input + 1,timelen) :: vmr_co2_gcm ! CO2 volume mixing ratio in the first layer [mol/m^3] |
|---|
| 69 | real, dimension(iim_input + 1,jjm_input + 1,timelen) :: ps_GCM ! Surface Pressure [Pa] |
|---|
| 70 | real, dimension(iim_input + 1,jjm_input + 1,nslope) :: min_co2_ice_dyn |
|---|
| 71 | real, dimension(iim_input + 1,jjm_input + 1,nslope) :: min_h2o_ice_dyn |
|---|
| 72 | real, dimension(iim_input + 1,jjm_input + 1,nslope) :: tsurf_ave_dyn ! Average surface temperature of the concatenated file [K] |
|---|
| 73 | real, dimension(iim_input + 1,jjm_input + 1,nsoilmx,nslope) :: tsoil_ave_dyn ! Average soil temperature of the concatenated file [K] |
|---|
| 74 | real, dimension(iim_input + 1,jjm_input + 1,nslope,timelen) :: tsurf_gcm_dyn ! Surface temperature of the concatenated file, time series [K] |
|---|
| 75 | real, dimension(iim_input + 1,jjm_input + 1,nsoilmx,nslope,timelen) :: tsoil_gcm_dyn ! Soil temperature of the concatenated file, time series [K] |
|---|
| 76 | real, dimension(iim_input + 1,jjm_input + 1,timelen) :: q_co2_dyn ! CO2 mass mixing ratio in the first layer [kg/m^3] |
|---|
| 77 | real, dimension(iim_input + 1,jjm_input + 1,timelen) :: q_h2o_dyn ! H2O mass mixing ratio in the first layer [kg/m^3] |
|---|
| 78 | real, dimension(iim_input + 1,jjm_input + 1,nslope,timelen) :: co2_ice_slope_dyn ! co2 ice amount per slope of the year [kg/m^2] |
|---|
| 79 | real, dimension(iim_input + 1,jjm_input + 1,nslope,timelen) :: watersurf_density_dyn ! Water density at the surface, time series [kg/m^3] |
|---|
| 80 | real, dimension(iim_input + 1,jjm_input + 1,nslope) :: watersurf_density_dyn_ave ! Water density at the surface, dynamic grid, yearly averaged [kg/m^3] |
|---|
| 81 | real, dimension(iim_input + 1,jjm_input + 1,nsoilmx,nslope,timelen) :: watersoil_density_dyn ! Water density in the soil layer, time series [kg/m^3] |
|---|
| 82 | real, dimension(ngrid,nslope,timelen) :: watersurf_density ! Water density at the surface, physical grid, time series [kg/m^3] |
|---|
| 83 | !----------------------------------------------------------------------- |
|---|
| 84 | ! Open the NetCDF file |
|---|
| 85 | write(*,*) "Opening "//filename//"..." |
|---|
| 86 | call error_msg(NF90_OPEN(filename,NF90_NOWRITE,fID),"open",filename) |
|---|
| 87 | |
|---|
| 88 | ! Dowload the data from the file |
|---|
| 89 | call get_var3("ps",ps_GCM) |
|---|
| 90 | write(*,*) "Data for surface pressure downloaded!" |
|---|
| 91 | |
|---|
| 92 | call get_var3("co2_layer1",q_co2_dyn) |
|---|
| 93 | write(*,*) "Data for vmr co2 downloaded!" |
|---|
| 94 | |
|---|
| 95 | call get_var3("h2o_layer1",q_h2o_dyn) |
|---|
| 96 | write(*,*) "Data for vmr h2o downloaded!" |
|---|
| 97 | |
|---|
| 98 | if (nslope == 1) then ! There is no slope |
|---|
| 99 | call get_var3("co2ice",co2_ice_slope_dyn(:,:,1,:)) |
|---|
| 100 | write(*,*) "Data for co2_ice downloaded!" |
|---|
| 101 | |
|---|
| 102 | call get_var3("h2o_ice_s",h2o_ice_s_dyn(:,:,1,:)) |
|---|
| 103 | write(*,*) "Data for h2o_ice_s downloaded!" |
|---|
| 104 | |
|---|
| 105 | #ifndef CPP_STD |
|---|
| 106 | call get_var3("watercap",watercap(:,:,1,:)) |
|---|
| 107 | write(*,*) "Data for watercap downloaded!" |
|---|
| 108 | #endif |
|---|
| 109 | |
|---|
| 110 | call get_var3("tsurf",tsurf_gcm_dyn(:,:,1,:)) |
|---|
| 111 | write(*,*) "Data for tsurf downloaded!" |
|---|
| 112 | |
|---|
| 113 | #ifndef CPP_STD |
|---|
| 114 | if (soil_pem) then |
|---|
| 115 | call get_var4("soiltemp",tsoil_gcm_dyn(:,:,:,1,:)) |
|---|
| 116 | write(*,*) "Data for soiltemp downloaded!" |
|---|
| 117 | |
|---|
| 118 | call get_var4("Waterdensity_soil",watersoil_density_dyn(:,:,:,1,:)) |
|---|
| 119 | write(*,*) "Data for waterdensity_soil downloaded!" |
|---|
| 120 | |
|---|
| 121 | call get_var3("Waterdensity_surface",watersurf_density_dyn(:,:,1,:)) |
|---|
| 122 | write(*,*) "Data for waterdensity_surface downloaded!" |
|---|
| 123 | endif !soil_pem |
|---|
| 124 | #endif |
|---|
| 125 | else ! We use slopes |
|---|
| 126 | do islope = 1,nslope |
|---|
| 127 | write(num,'(i2.2)') islope |
|---|
| 128 | call get_var3("co2ice_slope"//num,co2_ice_slope_dyn(:,:,islope,:)) |
|---|
| 129 | enddo |
|---|
| 130 | write(*,*) "Data for co2_ice downloaded!" |
|---|
| 131 | |
|---|
| 132 | do islope = 1,nslope |
|---|
| 133 | write(num,'(i2.2)') islope |
|---|
| 134 | call get_var3("h2o_ice_s_slope"//num,h2o_ice_s_dyn(:,:,islope,:)) |
|---|
| 135 | enddo |
|---|
| 136 | write(*,*) "Data for h2o_ice_s downloaded!" |
|---|
| 137 | |
|---|
| 138 | #ifndef CPP_STD |
|---|
| 139 | do islope = 1,nslope |
|---|
| 140 | write(num,'(i2.2)') islope |
|---|
| 141 | call get_var3("watercap_slope"//num,watercap(:,:,islope,:)) |
|---|
| 142 | enddo |
|---|
| 143 | write(*,*) "Data for watercap downloaded!" |
|---|
| 144 | #endif |
|---|
| 145 | |
|---|
| 146 | do islope = 1,nslope |
|---|
| 147 | write(num,'(i2.2)') islope |
|---|
| 148 | call get_var3("tsurf_slope"//num,tsurf_gcm_dyn(:,:,islope,:)) |
|---|
| 149 | enddo |
|---|
| 150 | write(*,*) "Data for tsurf downloaded!" |
|---|
| 151 | |
|---|
| 152 | #ifndef CPP_STD |
|---|
| 153 | if (soil_pem) then |
|---|
| 154 | do islope = 1,nslope |
|---|
| 155 | write(num,'(i2.2)') islope |
|---|
| 156 | call get_var4("soiltemp_slope"//num,tsoil_gcm_dyn(:,:,:,islope,:)) |
|---|
| 157 | enddo |
|---|
| 158 | write(*,*) "Data for soiltemp downloaded!" |
|---|
| 159 | |
|---|
| 160 | do islope = 1,nslope |
|---|
| 161 | write(num,'(i2.2)') islope |
|---|
| 162 | call get_var4("waterdensity_soil_slope"//num,watersoil_density_dyn(:,:,:,islope,:)) |
|---|
| 163 | enddo |
|---|
| 164 | write(*,*) "Data for waterdensity_soil downloaded!" |
|---|
| 165 | |
|---|
| 166 | do islope = 1,nslope |
|---|
| 167 | write(num,'(i2.2)') islope |
|---|
| 168 | call get_var3("waterdensity_surface"//num,watersurf_density_dyn(:,:,islope,:)) |
|---|
| 169 | enddo |
|---|
| 170 | write(*,*) "Data for waterdensity_surface downloaded!" |
|---|
| 171 | endif !soil_pem |
|---|
| 172 | #endif |
|---|
| 173 | endif |
|---|
| 174 | |
|---|
| 175 | ! Compute the minimum over the year for each point |
|---|
| 176 | write(*,*) "Computing the min of h2o_ice..." |
|---|
| 177 | where (h2o_ice_s_dyn < 0.) h2o_ice_s_dyn = 0. |
|---|
| 178 | min_h2o_ice_dyn(:,:,:) = minval(h2o_ice_s_dyn + watercap,4) |
|---|
| 179 | write(*,*) "Computing the min of co2_ice..." |
|---|
| 180 | where (co2_ice_slope_dyn < 0.) co2_ice_slope_dyn = 0. |
|---|
| 181 | min_co2_ice_dyn(:,:,:) = minval(co2_ice_slope_dyn,4) |
|---|
| 182 | |
|---|
| 183 | ! Compute averages over the year for each point |
|---|
| 184 | write(*,*) "Computing the average of tsurf..." |
|---|
| 185 | tsurf_ave_dyn(:,:,:) = sum(tsurf_gcm_dyn(:,:,:,:),4)/timelen |
|---|
| 186 | |
|---|
| 187 | if (soil_pem) then |
|---|
| 188 | write(*,*) "Computing average of tsoil..." |
|---|
| 189 | tsoil_ave_dyn(:,:,:,:) = sum(tsoil_gcm_dyn(:,:,:,:,:),5)/timelen |
|---|
| 190 | write(*,*) "Computing average of waterdensity_surface..." |
|---|
| 191 | watersurf_density_dyn_ave(:,:,:) = sum(watersurf_density_dyn(:,:,:,:),4)/timelen |
|---|
| 192 | endif |
|---|
| 193 | |
|---|
| 194 | ! By definition, we get rid of the negative values |
|---|
| 195 | A = (1./m_co2 - 1./m_noco2) |
|---|
| 196 | B = 1./m_noco2 |
|---|
| 197 | do i = 1,iim + 1 |
|---|
| 198 | do j = 1,jjm_input + 1 |
|---|
| 199 | do t = 1, timelen |
|---|
| 200 | if (q_co2_dyn(i,j,t) < 0) then |
|---|
| 201 | q_co2_dyn(i,j,t) = 1.e-10 |
|---|
| 202 | else if (q_co2_dyn(i,j,t) > 1) then |
|---|
| 203 | q_co2_dyn(i,j,t) = 1. |
|---|
| 204 | endif |
|---|
| 205 | if (q_h2o_dyn(i,j,t) < 0) then |
|---|
| 206 | q_h2o_dyn(i,j,t) = 1.e-30 |
|---|
| 207 | else if (q_h2o_dyn(i,j,t) > 1) then |
|---|
| 208 | q_h2o_dyn(i,j,t) = 1. |
|---|
| 209 | endif |
|---|
| 210 | mmean = 1/(A*q_co2_dyn(i,j,t) + B) |
|---|
| 211 | vmr_co2_gcm(i,j,t) = q_co2_dyn(i,j,t)*mmean/m_co2 |
|---|
| 212 | enddo |
|---|
| 213 | enddo |
|---|
| 214 | enddo |
|---|
| 215 | |
|---|
| 216 | #ifndef CPP_1D |
|---|
| 217 | call gr_dyn_fi(timelen,iim_input + 1,jjm_input + 1,ngrid,vmr_co2_gcm,vmr_co2_gcm_phys) |
|---|
| 218 | call gr_dyn_fi(timelen,iim_input + 1,jjm_input + 1,ngrid,ps_GCM,ps_timeseries) |
|---|
| 219 | call gr_dyn_fi(timelen,iim_input + 1,jjm_input + 1,ngrid,q_co2_dyn,q_co2) |
|---|
| 220 | call gr_dyn_fi(timelen,iim_input + 1,jjm_input + 1,ngrid,q_h2o_dyn,q_h2o) |
|---|
| 221 | |
|---|
| 222 | do islope = 1,nslope |
|---|
| 223 | call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,min_co2_ice_dyn(:,:,islope),min_co2_ice(:,islope)) |
|---|
| 224 | call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,min_h2o_ice_dyn(:,:,islope),min_h2o_ice(:,islope)) |
|---|
| 225 | if (soil_pem) then |
|---|
| 226 | do l = 1,nsoilmx |
|---|
| 227 | call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,tsoil_ave_dyn(:,:,l,islope),tsoil_ave(:,l,islope)) |
|---|
| 228 | do t = 1,timelen |
|---|
| 229 | call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,tsoil_gcm_dyn(:,:,l,islope,t),tsoil_gcm(:,l,islope,t)) |
|---|
| 230 | call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,watersoil_density_dyn(:,:,l,islope,t),watersoil_density(:,l,islope,t)) |
|---|
| 231 | enddo |
|---|
| 232 | enddo |
|---|
| 233 | call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,watersurf_density_dyn_ave(:,:,islope),watersurf_density_ave(:,islope)) |
|---|
| 234 | endif ! soil_pem |
|---|
| 235 | do t = 1,timelen |
|---|
| 236 | call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,tsurf_GCM_dyn(:,:,islope,t),tsurf_GCM(:,islope,t)) |
|---|
| 237 | call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,co2_ice_slope_dyn(:,:,islope,t),co2_ice_slope(:,islope,t)) |
|---|
| 238 | enddo |
|---|
| 239 | enddo |
|---|
| 240 | |
|---|
| 241 | call gr_dyn_fi(nslope,iim_input + 1,jjm_input + 1,ngrid,tsurf_ave_dyn,tsurf_ave) |
|---|
| 242 | #else |
|---|
| 243 | vmr_co2_gcm_phys(1,:) = vmr_co2_gcm(1,1,:) |
|---|
| 244 | ps_timeseries(1,:) = ps_GCM(1,1,:) |
|---|
| 245 | q_co2(1,:) = q_co2_dyn(1,1,:) |
|---|
| 246 | q_h2o(1,:) = q_h2o_dyn(1,1,:) |
|---|
| 247 | min_co2_ice(1,:) = min_co2_ice_dyn(1,1,:) |
|---|
| 248 | min_h2o_ice(1,:) = min_h2o_ice_dyn(1,1,:) |
|---|
| 249 | if (soil_pem) then |
|---|
| 250 | tsoil_ave(1,:,:) = tsoil_ave_dyn(1,1,:,:) |
|---|
| 251 | tsoil_gcm(1,:,:,:) = tsoil_gcm_dyn(1,1,:,:,:) |
|---|
| 252 | watersoil_density(1,:,:,:) = watersoil_density_dyn(1,1,:,:,:) |
|---|
| 253 | watersurf_density_ave(1,:) = watersurf_density_dyn_ave(1,1,:) |
|---|
| 254 | endif ! soil_pem |
|---|
| 255 | tsurf_GCM(1,:,:) = tsurf_GCM_dyn(1,1,:,:) |
|---|
| 256 | co2_ice_slope(1,:,:) = co2_ice_slope_dyn(1,1,:,:) |
|---|
| 257 | tsurf_ave(1,:) = tsurf_ave_dyn(1,1,:) |
|---|
| 258 | #endif |
|---|
| 259 | |
|---|
| 260 | END SUBROUTINE read_data_PCM |
|---|
| 261 | |
|---|
| 262 | !======================================================================= |
|---|
| 263 | |
|---|
| 264 | SUBROUTINE check_dim(n1,n2,str1,str2) |
|---|
| 265 | |
|---|
| 266 | implicit none |
|---|
| 267 | |
|---|
| 268 | integer, intent(in) :: n1, n2 |
|---|
| 269 | character(len = *), intent(in) :: str1, str2 |
|---|
| 270 | |
|---|
| 271 | character(256) :: s1, s2 |
|---|
| 272 | |
|---|
| 273 | if (n1 /= n2) then |
|---|
| 274 | s1 = 'value of '//trim(str1)//' =' |
|---|
| 275 | s2 = ' read in starting file differs from parametrized '//trim(str2)//' =' |
|---|
| 276 | write(msg,'(10x,a,i4,2x,a,i4)')trim(s1),n1,trim(s2),n2 |
|---|
| 277 | call abort_gcm(trim(modname),trim(msg),1) |
|---|
| 278 | endif |
|---|
| 279 | |
|---|
| 280 | END SUBROUTINE check_dim |
|---|
| 281 | |
|---|
| 282 | !======================================================================= |
|---|
| 283 | |
|---|
| 284 | SUBROUTINE get_var1(filename,v) |
|---|
| 285 | |
|---|
| 286 | implicit none |
|---|
| 287 | |
|---|
| 288 | character(len = *), intent(in) :: filename |
|---|
| 289 | real, dimension(:), intent(out) :: v |
|---|
| 290 | |
|---|
| 291 | call error_msg(NF90_INQ_VARID(fID,filename,vID),"inq",filename) |
|---|
| 292 | call error_msg(NF90_GET_VAR(fID,vID,v),"get",filename) |
|---|
| 293 | |
|---|
| 294 | END SUBROUTINE get_var1 |
|---|
| 295 | |
|---|
| 296 | !======================================================================= |
|---|
| 297 | |
|---|
| 298 | SUBROUTINE get_var3(filename,v) ! on U grid |
|---|
| 299 | |
|---|
| 300 | implicit none |
|---|
| 301 | |
|---|
| 302 | character(len = *), intent(in) :: filename |
|---|
| 303 | real, dimension(:,:,:), intent(out) :: v |
|---|
| 304 | |
|---|
| 305 | call error_msg(NF90_INQ_VARID(fID,filename,vID),"inq",filename) |
|---|
| 306 | call error_msg(NF90_GET_VAR(fID,vID,v),"get",filename) |
|---|
| 307 | |
|---|
| 308 | END SUBROUTINE get_var3 |
|---|
| 309 | |
|---|
| 310 | !======================================================================= |
|---|
| 311 | |
|---|
| 312 | SUBROUTINE get_var4(filename,v) |
|---|
| 313 | |
|---|
| 314 | implicit none |
|---|
| 315 | |
|---|
| 316 | character(len = *), intent(in) :: filename |
|---|
| 317 | real, dimension(:,:,:,:), intent(out) :: v |
|---|
| 318 | |
|---|
| 319 | call error_msg(NF90_INQ_VARID(fID,filename,vID),"inq",filename) |
|---|
| 320 | call error_msg(NF90_GET_VAR(fID,vID,v),"get",filename) |
|---|
| 321 | |
|---|
| 322 | END SUBROUTINE get_var4 |
|---|
| 323 | |
|---|
| 324 | !======================================================================= |
|---|
| 325 | |
|---|
| 326 | SUBROUTINE error_msg(ierr,typ,nam) |
|---|
| 327 | |
|---|
| 328 | implicit none |
|---|
| 329 | |
|---|
| 330 | integer, intent(in) :: ierr !--- NetCDF ERROR CODE |
|---|
| 331 | character(len = *), intent(in) :: typ !--- TYPE OF OPERATION |
|---|
| 332 | character(len = *), intent(in) :: nam !--- FIELD/FILE NAME |
|---|
| 333 | |
|---|
| 334 | if (ierr == nf90_noerr) return |
|---|
| 335 | select case(typ) |
|---|
| 336 | case('inq'); msg="Field <"//trim(nam)//"> is missing" |
|---|
| 337 | case('get'); msg="Reading failed for <"//trim(nam)//">" |
|---|
| 338 | case('open'); msg="File opening failed for <"//trim(nam)//">" |
|---|
| 339 | case('close'); msg="File closing failed for <"//trim(nam)//">" |
|---|
| 340 | case default |
|---|
| 341 | write(*,*) 'There is no message for this error.' |
|---|
| 342 | error stop |
|---|
| 343 | end select |
|---|
| 344 | call abort_gcm(trim(modname),trim(msg),ierr) |
|---|
| 345 | |
|---|
| 346 | END SUBROUTINE error_msg |
|---|
| 347 | |
|---|
| 348 | END MODULE read_data_PCM_mod |
|---|