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