Changeset 3509 for trunk/LMDZ.MARS/libf/phymars/iostart.F90
- Timestamp:
- Nov 8, 2024, 4:59:55 PM (2 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.MARS/libf/phymars/iostart.F90
r2952 r3509 8 8 9 9 ! restartfi.nc file dimension identifiers: (see open_restartphy()) 10 INTEGER,SAVE :: idim1 ! "index" dimension 11 INTEGER,SAVE :: idim2 ! "physical_points" dimension 12 INTEGER,SAVE :: idim3 ! "subsurface_layers" dimension 13 INTEGER,SAVE :: idim4 ! "nlayer_plus_1" dimension 14 INTEGER,SAVE :: idim5 ! "number_of_advected_fields" dimension 15 INTEGER,SAVE :: idim6 ! "nlayer" dimension 16 INTEGER,SAVE :: idim7 ! "Time" dimension 17 INTEGER,SAVE :: idim8 ! "nslope" dimension 18 INTEGER,SAVE :: idim9 ! "nslope_plus_1" dimension 10 INTEGER,SAVE :: idim1 ! "index" dimension 11 INTEGER,SAVE :: idim2 ! "physical_points" dimension 12 INTEGER,SAVE :: idim3 ! "subsurface_layers" dimension 13 INTEGER,SAVE :: idim4 ! "nlayer_plus_1" dimension 14 INTEGER,SAVE :: idim5 ! "number_of_advected_fields" dimension 15 INTEGER,SAVE :: idim6 ! "nlayer" dimension 16 INTEGER,SAVE :: idim7 ! "Time" dimension 17 INTEGER,SAVE :: idim8 ! "nslope" dimension 18 INTEGER,SAVE :: idim9 ! "nslope_plus_1" dimension 19 INTEGER,SAVE :: idim10 ! "descriptor" dimension 20 INTEGER,SAVE :: idim11 ! "description_size" dimension 19 21 INTEGER,SAVE :: timeindex ! current time index (for time-dependent fields) 20 INTEGER,PARAMETER :: length=100 ! size of tab_cntrl array 21 22 INTEGER,PARAMETER :: length = 100 ! size of tab_cntrl array 23 INTEGER,PARAMETER :: ldscrpt = 35 ! size of dscrpt_tab_cntrl array 24 INTEGER,PARAMETER :: ndscrpt = 50 ! size of characters in dscrpt_tab_cntrl array 25 22 26 INTERFACE get_field 23 27 MODULE PROCEDURE Get_field_r1,Get_field_r2,Get_field_r3 24 28 END INTERFACE get_field 25 29 26 30 INTERFACE get_var 27 31 MODULE PROCEDURE get_var_r0,Get_var_r1,Get_var_r2,Get_var_r3 … … 33 37 34 38 INTERFACE put_var 35 MODULE PROCEDURE put_var_r0,put_var_r1,put_var_r2,put_var_r3 39 MODULE PROCEDURE put_var_r0,put_var_r1,put_var_r2,put_var_r3, put_var_c1 36 40 END INTERFACE put_var 37 41 38 PUBLIC nid_start, length 42 PUBLIC nid_start, length, ldscrpt, ndscrpt 39 43 PUBLIC get_field,get_var,put_field,put_var 40 44 PUBLIC inquire_dimension, inquire_dimension_length 41 45 PUBLIC inquire_field, inquire_field_ndims 42 46 PUBLIC open_startphy,close_startphy,open_restartphy,close_restartphy 43 47 44 48 CONTAINS 45 49 … … 178 182 179 183 END FUNCTION inquire_dimension_length 180 181 182 184 183 185 SUBROUTINE Get_Field_r1(field_name,field,found,timeindex) … … 566 568 ierr=NF90_DEF_DIM(nid_restart,"nslope",nslope,idim8) 567 569 IF (ierr/=NF90_NOERR) THEN 568 write(*,*)' phyredem: problem defining nslope dimension'569 write(*,*)trim(nf90_strerror(ierr)) 570 CALL ABORT570 write(*,*)'open_restartphy: problem defining nslope dimension' 571 write(*,*)trim(nf90_strerror(ierr)) 572 CALL abort_physic("open_restartphy","Failed defining nslope",1) 571 573 ENDIF 572 574 573 575 ierr=NF90_DEF_DIM(nid_restart,"inter_slope",nslope+1,idim9) 574 576 IF (ierr/=NF90_NOERR) THEN 575 write(*,*)'phyredem: problem defining inter slope dimension' 576 write(*,*)trim(nf90_strerror(ierr)) 577 CALL ABORT 577 write(*,*)'open_restartphy: problem defining inter_slope dimension' 578 write(*,*)trim(nf90_strerror(ierr)) 579 CALL abort_physic("open_restartphy","Failed defining inter_slope",1) 580 ENDIF 581 582 ierr=NF90_DEF_DIM(nid_restart,"descriptor",ldscrpt,idim10) 583 IF (ierr/=NF90_NOERR) THEN 584 write(*,*)'open_restartphy: problem defining descriptor dimension ' 585 write(*,*)trim(nf90_strerror(ierr)) 586 CALL abort_physic("open_restartphy","Failed defining descriptor",1) 587 ENDIF 588 589 ierr=NF90_DEF_DIM(nid_restart,"description_size",ndscrpt,idim11) 590 IF (ierr/=NF90_NOERR) THEN 591 write(*,*)'open_restartphy: problem defining description_size dimension ' 592 write(*,*)trim(nf90_strerror(ierr)) 593 CALL abort_physic("open_restartphy","Failed defining description_size",1) 578 594 ENDIF 579 595 … … 946 962 END SUBROUTINE put_var_r0 947 963 948 949 964 SUBROUTINE put_var_r1(var_name,title,var) 950 965 ! Put a vector in file … … 967 982 CALL put_var_rgen(var_name,title,var,size(var)) 968 983 969 END SUBROUTINE put_var_r2 984 END SUBROUTINE put_var_r2 970 985 971 986 SUBROUTINE put_var_r3(var_name,title,var) … … 1029 1044 write(*,*)'put_var_rgen: problem writing Time' 1030 1045 write(*,*)trim(nf90_strerror(ierr)) 1031 CALL abort_physic(" get_var_rgen","Failed to write Time",1)1046 CALL abort_physic("put_var_rgen","Failed to write Time",1) 1032 1047 ENDIF 1033 1048 return ! nothing left to do … … 1036 1051 idim1d=idim1 1037 1052 ELSEIF (var_size==nsoilmx) THEN 1038 ! We know it is an 1053 ! We know it is an "mlayer" kind of 1D array 1039 1054 idim1d=idim3 1040 1055 ELSEIF (var_size==nslope+1) THEN 1041 ! We know it is an 1056 ! We know it is an "inter slope" kind of 1D array 1042 1057 idim1d=idim9 1043 1058 ELSE 1044 1059 PRINT *, "put_var_rgen error : wrong dimension" 1045 1060 write(*,*) " var_size =",var_size 1046 CALL abort_physic(" get_var_rgen","Wrong variable dimension",1)1061 CALL abort_physic("put_var_rgen","Wrong variable dimension",1) 1047 1062 1048 1063 ENDIF ! of IF (var_size==length) THEN … … 1070 1085 ENDIF ! of IF (is_master) 1071 1086 1072 END SUBROUTINE put_var_rgen 1087 END SUBROUTINE put_var_rgen 1088 1089 SUBROUTINE put_var_c1(var_name,title,var) 1090 ! Put a vector of characters in file 1091 1092 USE netcdf, only: NF90_REDEF, NF90_DEF_VAR, NF90_ENDDEF, NF90_PUT_VAR, & 1093 NF90_CHAR, & 1094 NF90_PUT_ATT, NF90_NOERR, nf90_strerror, & 1095 nf90_inq_dimid, nf90_inquire_dimension, NF90_INQ_VARID 1096 USE comsoil_h, only: nsoilmx 1097 USE comslope_mod, only: nslope 1098 USE mod_phys_lmdz_para, only: is_master 1099 1100 IMPLICIT NONE 1101 CHARACTER(LEN=*),INTENT(IN) :: var_name 1102 CHARACTER(LEN=*),INTENT(IN) :: title 1103 CHARACTER(LEN=*),INTENT(IN) :: var(:) 1104 1105 INTEGER :: ierr 1106 INTEGER :: nvarid 1107 INTEGER :: idim1d_1, idim1d_2 1108 INTEGER :: var_size 1109 logical,save :: firsttime=.true. 1110 1111 IF (is_master) THEN 1112 1113 var_size = size(var) 1114 IF (var_size==ldscrpt) THEN 1115 ! We know it is a "controle descriptor" kind of 1D array 1116 idim1d_1=idim11 1117 idim1d_2=idim10 1118 ELSE 1119 PRINT *, "put_var_cgen error : wrong dimension" 1120 write(*,*) " var_size =",var_size 1121 CALL abort_physic("put_var_cgen","Wrong variable dimension",1) 1122 1123 ENDIF ! of IF (var_size==length) THEN 1124 1125 ! Swich to NetCDF define mode 1126 ierr=NF90_REDEF (nid_restart) 1127 ! Define the variable 1128 ierr=NF90_DEF_VAR(nid_restart,var_name,NF90_CHAR,(/idim1d_1,idim1d_2/),nvarid) 1129 ! Add a "title" attribute 1130 IF (LEN_TRIM(title)>0) ierr=NF90_PUT_ATT(nid_restart,nvarid,"title",title) 1131 ! Swich out of define mode 1132 ierr=NF90_ENDDEF(nid_restart) 1133 ! Write variable to file 1134 ierr=NF90_PUT_VAR(nid_restart,nvarid,var) 1135 IF (ierr/=NF90_NOERR) THEN 1136 write(*,*)'put_var_cgen: problem writing '//trim(var_name) 1137 write(*,*)trim(nf90_strerror(ierr)) 1138 CALL abort_physic("put_var_cgen","Failed writing variable",1) 1139 ENDIF 1140 ENDIF ! of IF (is_master) 1141 1142 END SUBROUTINE put_var_c1 1073 1143 1074 1144 END MODULE iostart
Note: See TracChangeset
for help on using the changeset viewer.