Changeset 2567 for trunk/LMDZ.MARS/util/hrecast.F90
- Timestamp:
- Oct 5, 2021, 8:34:09 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.MARS/util/hrecast.F90
r2140 r2567 116 116 if (ierr.ne.NF_NOERR) then 117 117 write(*,*) 'ERROR: Pb opening file ',trim(infile) 118 stop ""118 stop 119 119 endif 120 120 … … 189 189 write(*,*) 'No variables to process !?' 190 190 write(*,*) 'Might as well stop here' 191 stop ""191 stop 192 192 else 193 193 write(*,*) "" … … 209 209 ierr=NF_INQ_DIMID(infid,"latitude",tmpdimid) 210 210 if (ierr.ne.NF_NOERR) then 211 stop "Error: Failed to get latitude dimension ID" 211 write(*,*) "Error: Failed to get latitude dimension ID" 212 stop 212 213 else 213 214 ierr=NF_INQ_VARID(infid,"latitude",tmpvarid) 214 215 if (ierr.ne.NF_NOERR) then 215 stop "Error: Failed to get latitude ID" 216 write(*,*) "Error: Failed to get latitude ID" 217 stop 216 218 else 217 219 ierr=NF_INQ_DIMLEN(infid,tmpdimid,inlatlength) 218 220 if (ierr.ne.NF_NOERR) then 219 stop "Error: Failed to get latitude length" 221 write(*,*) "Error: Failed to get latitude length" 222 stop 220 223 else 221 224 allocate(inlat(inlatlength)) 222 225 ierr=NF_GET_VAR_REAL(infid,tmpvarid,inlat) 223 226 if (ierr.ne.NF_NOERR) then 224 stop "Error: Failed reading latitude" 227 write(*,*) "Error: Failed reading latitude" 228 stop 225 229 endif 226 230 endif … … 244 248 ierr=NF_INQ_DIMID(infid,"longitude",tmpdimid) 245 249 if (ierr.ne.NF_NOERR) then 246 stop "Error: Failed to get longitude dimension ID" 250 write(*,*) "Error: Failed to get longitude dimension ID" 251 stop 247 252 else 248 253 ierr=NF_INQ_VARID(infid,"longitude",tmpvarid) 249 254 if (ierr.ne.NF_NOERR) then 250 stop "Error: Failed to get longitude ID" 255 write(*,*) "Error: Failed to get longitude ID" 256 stop 251 257 else 252 258 ierr=NF_INQ_DIMLEN(infid,tmpdimid,inlonlength) 253 259 if (ierr.ne.NF_NOERR) then 254 stop "Error: Failed to get longitude length" 260 write(*,*) "Error: Failed to get longitude length" 261 stop 255 262 else 256 263 allocate(inlon(inlonlength)) 257 264 ierr=NF_GET_VAR_REAL(infid,tmpvarid,inlon) 258 265 if (ierr.ne.NF_NOERR) then 259 stop "Error: Failed reading longitude" 266 write(*,*) "Error: Failed reading longitude" 267 stop 260 268 endif 261 269 endif … … 279 287 ierr=NF_INQ_DIMID(infid,"altitude",tmpdimid) 280 288 if (ierr.ne.NF_NOERR) then 281 stop "Error: Failed to get altitude dimension ID" 289 write(*,*) "Error: Failed to get altitude dimension ID" 290 stop 282 291 else 283 292 ierr=NF_INQ_VARID(infid,"altitude",tmpvarid) 284 293 if (ierr.ne.NF_NOERR) then 285 stop "Error: Failed to get altitude ID" 294 write(*,*) "Error: Failed to get altitude ID" 295 stop 286 296 else 287 297 ierr=NF_INQ_DIMLEN(infid,tmpdimid,altlength) 288 298 if (ierr.ne.NF_NOERR) then 289 stop "Error: Failed to get altitude length" 299 write(*,*) "Error: Failed to get altitude length" 300 stop 290 301 else 291 302 allocate(alt(altlength)) 292 303 ierr=NF_GET_VAR_REAL(infid,tmpvarid,alt) 293 304 if (ierr.ne.NF_NOERR) then 294 stop "Error: Failed reading altitude" 305 write(*,*) "Error: Failed reading altitude" 306 stop 295 307 endif 296 308 endif … … 301 313 ierr=NF_INQ_DIMID(infid,"Time",tmpdimid) 302 314 if (ierr.ne.NF_NOERR) then 303 stop "Error: Failed to get Time dimension ID" 315 write(*,*) "Error: Failed to get Time dimension ID" 316 stop 304 317 else 305 318 ierr=NF_INQ_VARID(infid,"Time",tmpvarid) 306 319 if (ierr.ne.NF_NOERR) then 307 stop "Error: Failed to get Time ID" 320 write(*,*) "Error: Failed to get Time ID" 321 stop 308 322 else 309 323 ierr=NF_INQ_DIMLEN(infid,tmpdimid,timelength) 310 324 if (ierr.ne.NF_NOERR) then 311 stop "Error: Failed to get Time length" 325 write(*,*) "Error: Failed to get Time length" 326 stop 312 327 else 313 328 allocate(time(timelength)) 314 329 ierr=NF_GET_VAR_REAL(infid,tmpvarid,time) 315 330 if (ierr.ne.NF_NOERR) then 316 stop "Error: Failed reading Time" 331 write(*,*) "Error: Failed reading Time" 332 stop 317 333 endif 318 334 endif … … 332 348 ierr=NF_GET_VAR_REAL(infid,tmpvarid,sigma) 333 349 if (ierr.ne.NF_NOERR) then 334 stop "Error: Failed reading sigma" 350 write(*,*) "Error: Failed reading sigma" 351 stop 335 352 endif 336 353 endif … … 341 358 ierr=NF_INQ_VARID(infid,"aps",tmpvarid) 342 359 if (ierr.ne.NF_NOERR) then 343 stop "Error: Failed to get aps ID" 360 write(*,*) "Error: Failed to get aps ID" 361 stop 344 362 else 345 363 allocate(aps(altlength)) 346 364 ierr=NF_GET_VAR_REAL(infid,tmpvarid,aps) 347 365 if (ierr.ne.NF_NOERR) then 348 stop "Error: Failed reading aps" 366 write(*,*) "Error: Failed reading aps" 367 stop 349 368 endif 350 369 endif … … 353 372 ierr=NF_INQ_VARID(infid,"bps",tmpvarid) 354 373 if (ierr.ne.NF_NOERR) then 355 stop "Error: Failed to get bps ID" 374 write(*,*) "Error: Failed to get bps ID" 375 stop 356 376 else 357 377 allocate(bps(altlength)) 358 378 ierr=NF_GET_VAR_REAL(infid,tmpvarid,bps) 359 379 if (ierr.ne.NF_NOERR) then 360 stop "Error: Failed reading bps" 380 write(*,*) "Error: Failed reading bps" 381 stop 361 382 endif 362 383 endif … … 377 398 ierr=NF_GET_VAR_REAL(infid,tmpvarid,inphisinit) 378 399 if (ierr.ne.NF_NOERR) then 379 stop "Error: Failed reading phisinit" 400 write(*,*) "Error: Failed reading phisinit" 401 stop 380 402 endif 381 403 endif … … 525 547 ierr=NF_DEF_DIM(outfid,"longitude",lonlength,lon_dimid) 526 548 if (ierr.ne.NF_NOERR) then 527 stop "Error: Could not define longitude dimension" 549 write(*,*) "Error: Could not define longitude dimension" 550 stop 528 551 endif 529 552 … … 531 554 ierr=NF_DEF_DIM(outfid,"latitude",latlength,lat_dimid) 532 555 if (ierr.ne.NF_NOERR) then 533 stop "Error: Could not define latitude dimension" 556 write(*,*) "Error: Could not define latitude dimension" 557 stop 534 558 endif 535 559 … … 537 561 ierr=NF_DEF_DIM(outfid,"altitude",altlength,alt_dimid) 538 562 if (ierr.ne.NF_NOERR) then 539 stop "Error: Could not define altitude dimension" 563 write(*,*) "Error: Could not define altitude dimension" 564 stop 540 565 endif 541 566 … … 543 568 ierr=NF_DEF_DIM(outfid,"Time",NF_UNLIMITED,time_dimid) 544 569 if (ierr.ne.NF_NOERR) then 545 stop "Error: Could not define latitude dimension" 570 write(*,*) "Error: Could not define latitude dimension" 571 stop 546 572 endif 547 573 … … 556 582 ierr=NF_DEF_VAR(outfid,"longitude",NF_REAL,1,datashape(1),lon_varid) 557 583 if (ierr.ne.NF_NOERR) then 558 stop "Error: Could not define longitude variable" 584 write(*,*) "Error: Could not define longitude variable" 585 stop 559 586 endif 560 587 … … 563 590 ierr=NF_PUT_ATT_TEXT(outfid,lon_varid,'long_name',len_trim(text),text) 564 591 if (ierr.ne.NF_NOERR) then 565 stop "Error: Problem writing long_name for longitude" 592 write(*,*) "Error: Problem writing long_name for longitude" 593 stop 566 594 endif 567 595 text='degrees_east' 568 596 ierr=NF_PUT_ATT_TEXT(outfid,lon_varid,'units',len_trim(text),text) 569 597 if (ierr.ne.NF_NOERR) then 570 stop "Error: Problem writing units for longitude" 598 write(*,*) "Error: Problem writing units for longitude" 599 stop 571 600 endif 572 601 … … 575 604 ierr=NF_DEF_VAR(outfid,"latitude",NF_REAL,1,datashape(2),lat_varid) 576 605 if (ierr.ne.NF_NOERR) then 577 stop "Error: Could not define latitude variable" 606 write(*,*) "Error: Could not define latitude variable" 607 stop 578 608 endif 579 609 … … 582 612 ierr=NF_PUT_ATT_TEXT(outfid,lat_varid,'long_name',len_trim(text),text) 583 613 if (ierr.ne.NF_NOERR) then 584 stop "Error: Problem writing long_name for latitude" 614 write(*,*) "Error: Problem writing long_name for latitude" 615 stop 585 616 endif 586 617 text='degrees_north' 587 618 ierr=NF_PUT_ATT_TEXT(outfid,lat_varid,'units',len_trim(text),text) 588 619 if (ierr.ne.NF_NOERR) then 589 stop "Error: Problem writing units for latitude" 620 write(*,*) "Error: Problem writing units for latitude" 621 stop 590 622 endif 591 623 … … 594 626 ierr=NF_DEF_VAR(outfid,"altitude",NF_REAL,1,datashape(3),alt_varid) 595 627 if (ierr.ne.NF_NOERR) then 596 stop "Error: Could not define altitude variable" 628 write(*,*) "Error: Could not define altitude variable" 629 stop 597 630 endif 598 631 … … 629 662 ierr=NF_DEF_VAR(outfid,"sigma",NF_REAL,1,alt_dimid,sigma_varid) 630 663 if (ierr.ne.NF_NOERR) then 631 stop "Error: Could not define sigma variable" 664 write(*,*) "Error: Could not define sigma variable" 665 stop 632 666 endif 633 667 else ! hybrid coordinates 634 668 ierr=NF_DEF_VAR(outfid,"aps",NF_REAL,1,alt_dimid,aps_varid) 635 669 if (ierr.ne.NF_NOERR) then 636 stop "Error: Could not define aps variable" 670 write(*,*) "Error: Could not define aps variable" 671 stop 637 672 endif 638 673 ierr=NF_DEF_VAR(outfid,"bps",NF_REAL,1,alt_dimid,bps_varid) 639 674 if (ierr.ne.NF_NOERR) then 640 stop "Error: Could not define bps variable" 675 write(*,*) "Error: Could not define bps variable" 676 stop 641 677 endif 642 678 endif … … 647 683 ierr=NF_PUT_ATT_TEXT(outfid,sigma_varid,'long_name',len_trim(text),text) 648 684 if (ierr.ne.NF_NOERR) then 649 stop "Error: Problem writing long_name for sigma" 685 write(*,*) "Error: Problem writing long_name for sigma" 686 stop 650 687 endif 651 688 else ! hybrid coordinates … … 653 690 ierr=NF_PUT_ATT_TEXT(outfid,aps_varid,'long_name',len_trim(text),text) 654 691 if (ierr.ne.NF_NOERR) then 655 stop "Error: Problem writing long_name for aps" 692 write(*,*) "Error: Problem writing long_name for aps" 693 stop 656 694 endif 657 695 text="hybrid sigma at midlayers" 658 696 ierr=NF_PUT_ATT_TEXT(outfid,bps_varid,'long_name',len_trim(text),text) 659 697 if (ierr.ne.NF_NOERR) then 660 stop "Error: Problem writing long_name for bps" 698 write(*,*) "Error: Problem writing long_name for bps" 699 stop 661 700 endif 662 701 endif ! of if (have_sigma) … … 666 705 ierr=NF_DEF_VAR(outfid,"Time",NF_REAL,1,datashape(4),time_varid) 667 706 if (ierr.ne.NF_NOERR) then 668 stop "Error: Could not define Time variable" 707 write(*,*) "Error: Could not define Time variable" 708 stop 669 709 endif 670 710 … … 683 723 ierr=NF_PUT_ATT_TEXT(outfid,time_varid,'units',len_trim(text),text) 684 724 if (ierr.ne.NF_NOERR) then 685 stop "Error: Problem writing units for Time" 725 write(*,*) "Error: Problem writing units for Time" 726 stop 686 727 endif 687 728 endif … … 694 735 ierr=NF_DEF_VAR(outfid,"phisinit",NF_REAL,2,datashape,phisinit_varid) 695 736 if (ierr.ne.NF_NOERR) then 696 stop "Error: Could not define phisinit variable" 737 write(*,*) "Error: Could not define phisinit variable" 738 stop 697 739 endif 698 740 endif … … 701 743 ierr=NF_PUT_ATT_TEXT(outfid,phisinit_varid,'long_name',len_trim(text),text) 702 744 if (ierr.ne.NF_NOERR) then 703 stop "Error: Problem writing long_name for phisinit" 745 write(*,*) "Error: Problem writing long_name for phisinit" 746 stop 704 747 endif 705 748 endif ! of if (have_geopot) … … 714 757 if (ierr.ne.NF_NOERR) then 715 758 write(*,*) 'Error, failed to get ID for input variable ',trim(var(i)) 716 stop ""759 stop 717 760 endif 718 761 … … 738 781 if (ierr.ne.NF_NOERR) then 739 782 write(*,*) 'Error, could not define variable ',trim(var(i)) 740 stop ""783 stop 741 784 endif 742 785 … … 747 790 write(*,*) 'Error, could not get number of attributes for variable ',& 748 791 trim(var(i)) 749 stop ""792 stop 750 793 endif 751 794 ! inititialize j == number of attributes written to output … … 766 809 if (ierr.ne.NF_NOERR) then 767 810 write(*,*) "Error failed to copy title attribute:",trim(text) 768 stop ""811 stop 769 812 endif 770 813 endif … … 775 818 if (ierr.ne.NF_NOERR) then 776 819 write(*,*) "Error failed to copy long_name attribute:",trim(text) 777 stop ""820 stop 778 821 endif 779 822 endif … … 789 832 if (ierr.ne.NF_NOERR) then 790 833 write(*,*) "Error failed to copy units attribute:",trim(text) 791 stop ""834 stop 792 835 endif 793 836 endif … … 805 848 ierr=NF_PUT_ATT_REAL(outfid,var_id(i),'missing_value',NF_REAL,1,miss_val) 806 849 if (ierr.ne.NF_NOERR) then 807 stop "Error, failed to write missing_value attribute" 850 write(*,*) "Error, failed to write missing_value attribute" 851 stop 808 852 endif 809 853 … … 823 867 ierr=NF_ENDDEF(outfid) 824 868 if (ierr.ne.NF_NOERR) then 825 stop "Error: Could not switch out of define mode" 869 write(*,*) "Error: Could not switch out of define mode" 870 stop 826 871 endif 827 872 … … 829 874 ierr=NF_PUT_VAR_REAL(outfid,lon_varid,lon) 830 875 if (ierr.ne.NF_NOERR) then 831 stop "Error: Could not write longitude data to output file" 876 write(*,*) "Error: Could not write longitude data to output file" 877 stop 832 878 endif 833 879 … … 835 881 ierr=NF_PUT_VAR_REAL(outfid,lat_varid,lat) 836 882 if (ierr.ne.NF_NOERR) then 837 stop "Error: Could not write latitude data to output file" 883 write(*,*) "Error: Could not write latitude data to output file" 884 stop 838 885 endif 839 886 … … 841 888 ierr=NF_PUT_VAR_REAL(outfid,alt_varid,alt) 842 889 if (ierr.ne.NF_NOERR) then 843 stop "Error: Could not write altitude data to output file" 890 write(*,*) "Error: Could not write altitude data to output file" 891 stop 844 892 endif 845 893 … … 848 896 ierr=NF_PUT_VAR_REAL(outfid,sigma_varid,sigma) 849 897 if (ierr.ne.NF_NOERR) then 850 stop "Error: Could not write sigma data to output file" 898 write(*,*) "Error: Could not write sigma data to output file" 899 stop 851 900 endif 852 901 else ! hybrid coordinates 853 902 ierr=NF_PUT_VAR_REAL(outfid,aps_varid,aps) 854 903 if (ierr.ne.NF_NOERR) then 855 stop "Error: Could not write aps data to output file" 904 write(*,*) "Error: Could not write aps data to output file" 905 stop 856 906 endif 857 907 ierr=NF_PUT_VAR_REAL(outfid,bps_varid,bps) 858 908 if (ierr.ne.NF_NOERR) then 859 stop "Error: Could not write bps data to output file" 909 write(*,*) "Error: Could not write bps data to output file" 910 stop 860 911 endif 861 912 endif 862 913 863 914 ! write time 864 ierr=NF_PUT_VARA_REAL(outfid,time_varid,1,timelength,time) 865 if (ierr.ne.NF_NOERR) then 866 stop "Error: Could not write Time data to output file" 915 ierr=NF_PUT_VARA_REAL(outfid,time_varid,(/1/),(/timelength/),time) 916 if (ierr.ne.NF_NOERR) then 917 write(*,*) "Error: Could not write Time data to output file" 918 stop 867 919 endif 868 920 … … 880 932 ierr=NF_INQ_VARID(infid,"phisinit",tmpvarid) 881 933 if (ierr.ne.NF_NOERR) then 882 stop "Error: Failed to get phisinit ID" 934 write(*,*) "Error: Failed to get phisinit ID" 935 stop 883 936 endif 884 937 ! Get physinit 885 938 ierr=NF_GET_VAR_REAL(infid,tmpvarid,in_2d_data) 886 939 if (ierr.ne.NF_NOERR) then 887 stop "Error: Failed reading input phisinit" 940 write(*,*) "Error: Failed reading input phisinit" 941 stop 888 942 endif 889 943 … … 903 957 ierr=NF_PUT_VAR_REAL(outfid,phisinit_varid,out_2d_data) 904 958 if (ierr.ne.NF_NOERR) then 905 stop "Error: Could not write phisinit data to output file" 959 write(*,*) "Error: Could not write phisinit data to output file" 960 stop 906 961 endif 907 962 endif ! of if (have_geopot) … … 1073 1128 1074 1129 REAL airen ((imnmx2+1)*(jmnmx2+1)) ! aire dans la nouvelle grille 1075 REAL airentotn 1076 REAL airentots 1130 REAL airentotn ! aire totale pole nord dans la nouvelle grille 1131 REAL airentots ! aire totale pole sud dans la nouvelle grille 1077 1132 ! Info sur les ktotal intersection entre les cases new/old grille 1078 1133
Note: See TracChangeset
for help on using the changeset viewer.